-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use Tornado default WebSocket check_origin function #125
Conversation
Tested locally, and it worked with no issues. Can't think of a deployment scenario right now where we would have issues, but if that happens, we should be able to find a workaround. Better than to leave it with no security protection to only add after something bad happens. Set to 0.3, will mark as ready for review after the 0.2 release 👍 |
Codecov Report
@@ Coverage Diff @@
## master #125 +/- ##
=========================================
- Coverage 52.56% 52.3% -0.26%
=========================================
Files 6 6
Lines 371 369 -2
Branches 58 58
=========================================
- Hits 195 193 -2
Misses 173 173
Partials 3 3
Continue to review full report at Codecov.
|
Added docs to the existing PR to |
f73e54d
to
a2ff234
Compare
Codecov Report
@@ Coverage Diff @@
## master #125 +/- ##
==========================================
- Coverage 51.00% 50.75% -0.25%
==========================================
Files 6 6
Lines 398 396 -2
Branches 64 64
==========================================
- Hits 203 201 -2
Misses 192 192
Partials 3 3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and found working 🥊
These changes close #109
When I implemented the WebSocket handler, I used an existing example from Tornado docs, which had the
check_origin
function. As I didn't know how to use it well, I've disabled this check so that it would cause less issues for development. Time to revisit it and refine/review.The function can be removed from the
SubscriptionHandler
. This will keep the parentWebSocketHandler
'scheck_origin
default behavior:Origin
HTTP header, then this function is ignoredcheck_origin
will returnTrue
meaning that the request passed the test, andFalse
otherwiseOrigin
HTTP header, removes protocol, fragments, path, etc, leaving only the domain part. Then compares against the value of the HTTP headerHost
. If the same, then the function will returnTrue
. Otherwise, it means the connection is coming from another host (e.g. someone could be trying to connect to the WebSocket from mydashboard.somesite.com).The risk without this, is that CORS/XORS attacks would be possible. Where someone could set up a site somewhere else and try to send malicious messages down the stream to the server. We have other authentication mechanisms in place to prevent that, but it's still recommended to enable this (both by OWASP and by the Tornado docs).
Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.