Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking Cross Origin WebSocket Attempt - behind load balancer #46

Open
timkpaine opened this issue May 15, 2019 · 4 comments
Open

Blocking Cross Origin WebSocket Attempt - behind load balancer #46

timkpaine opened this issue May 15, 2019 · 4 comments

Comments

@timkpaine
Copy link

timkpaine commented May 15, 2019

When running behind a load balancer/proxy, I get this error:
Blocking Cross Origin WebSocket Attempt
because the Host header doesn't match the Origin header (from here). However, this is supposed to be the case, as the "real" host will be in Forwarded or X-Forwarded-Host.

Would it make sense to check if these are set, and if so, to prefer them to the Host header when comparing to Origin?

@afshin
Copy link
Contributor

afshin commented May 15, 2019

What you suggest sounds like the correct behavior. It's not part of the standard, but it's a "de facto standard"

@yuvipanda
Copy link
Contributor

Gotta be careful when X-Forwarded-Host unconditionally. See rails/rails#29893 for an example of unforeseen security issues. A bunch of other web frameworks have features that list you explicitly set which IPs to trust X-Forwarded-Host headers from - https://expressjs.com/en/guide/behind-proxies.html.

This might not be a problem here for CORS, but something to carefully consider regardless

@rolweber
Copy link
Contributor

Would it make sense to check if these are set, and if so, to prefer them to the Host header when comparing to Origin?

Definitely not. Any attacker can set headers as they wish, so it's a bad idea to disable security checks based on the fact that some header is present. Explicitly telling Jupyter through the configuration that it is running behind a load balancer, as suggested by @yuvipanda, sounds like the way to go.

@rolweber
Copy link
Contributor

rolweber commented May 20, 2019

Maybe add logic around this line to use the value from a configured header (Forwarded or X-Forwarded-Host or whatever) in favor of the value from the Host header. The latter should still be used as a fallback in the absence of the configured header, in case somebody is hitting the same server directly instead of through the load balancer.

On second thought, it might still be possible to abuse this by hitting the server directly. Tricky thing.

@Zsailer Zsailer added this to the Future milestone Dec 2, 2019
@Zsailer Zsailer removed this from the Future milestone Apr 15, 2020
Zsailer pushed a commit to Zsailer/jupyter_server that referenced this issue Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants