-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Websocket hijacking vulnerability #128
Comments
Can you explain in detail what is the exploit that you found? |
Sorry for the lack of details. How it worksAssuming we are hosting a crafted HTML Page at It works like CSRF, but in websocket world it called Cross-Site WebSocket Hijacking (CSWSH) WhyWebsocket connections not bound by CORS, and python-engineio only used CORS headers for rejecting invalid Origin connections FixAbort invalid |
Here is a temporary fix: @socket_io.on('connect', namespace='/ns')
def on_client_connect():
if request.headers.get('Origin', 'invalid') not in socket_io.server_options.get('cors_allowed_origins', []):
logging.warning('WebSocket Hijacking detected from domain "%s"' % request.headers.get('Origin', 'invalid'))
disconnect() # return False in connect handler not working?
return False And we can see the hijacking attempts that from
|
Okay, makes sense, thanks. |
This was assigned CVE-2019-13611. |
Hi, I work on GitHub's security workflows team, and we are currently evaluating CVE-2019-13611 as it is in our holding pattern for publishing. We would like to reach out to you, and get some feedback as we plan to publish this soon, however we would like to ensure that we are responsibly disclosing this information. |
Hi @benSlaughter. This is basically a vulnerability in the WebSocket protocol, not in this package. The actual issue is the lack of CORS controls for WebSocket connections in browsers. This package uses several WebSocket implementations as optional dependencies that allow clients to establish WebSocket connections, so someone has decided that this package needs to do this validation that browsers don't do. I have been thinking about this to see if there is anything I can do from my side to address this in a way that is generic and works with all the WebSocket server implementations I support, but I honestly feel this should be better done in each WebSocket implementation. |
I believe I have addressed this problem by implementing the recommended verification of the origin header when present in incoming requests. Unfortunately rolling out this fix will take a bit of orchestration on my part as I want to minimize breaking people's code. There are a couple other packages that depend on this one that will also need their versions and dependencies bumped like this one to make it clear that upgrading could be potentially backwards incompatible. I expect the fix will be rolled out later in the week. |
Hi @miguelgrinberg thanks so much for getting back to me. |
@benSlaughter how will you know which version(s) are affected? The advisory does not have any fields to indicate the version range. Thanks. |
Hi @miguelgrinberg |
CORS headers are only works in XHR requests, and ignored by clients during a websocket connection.
Ref: https://tools.ietf.org/html/rfc6455#section-4.2.2
TLDR;
If the server does not wish to accept this connection, it MUST return an appropriate HTTP error code (e.g., 403 Forbidden) and abort the WebSocket handshake
The text was updated successfully, but these errors were encountered: