-
Notifications
You must be signed in to change notification settings - Fork 350
CORS is not checked when browsing files. check origin now https://github.com/jupyter-server/jupyter_server/issues/1459 #1465
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
Conversation
@gogasca Thanks for the issue and the PR. I've been reading it, and agree that the Happy for any input you have on the above, and thanks again! |
Thanks @vidartf I will test using |
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.
Change self.check_origin() to check_referer()
After changing: Change self.check_origin() to check_referer() many tests cases are broken, reverting back to self.check_origin() |
@vidartf can you PTAL again? |
1 similar comment
@gogasca apologies that this has taken so long to review. I updated the top level comment to give more information here. @vidartf You raise a valid concern about consistency with existing behavior. Here's my analysis: Key Differences Between Methods
The Trade-offYour suggestion to use check_referer() for GET/HEAD requests is technically correct for consistency, but
My Recommendation
try:
if self.request.method in {"GET", "HEAD"}:
if not self.check_referer():
raise web.HTTPError(404)
else:
if not self.check_origin():
raise web.HTTPError(404)
return super().check_xsrf_cookie()
except web.HTTPError as e:
# Existing fallback logic remains unchanged
ConclusionI think the current PR is acceptable as-is for the security fix. The architectural improvement (using |
Thank you @gogasca for your patience here! |
Add check_origin check during check_xsrf_cookie for files.
Details: #1459
Summary
This PR addresses a CORS bypass vulnerability in the /files endpoint. The issue allows attackers to bypass
configured CORS restrictions (allow_origin_pat) by exploiting the XSRF token validation flow.
The Vulnerability
The current check_xsrf_cookie() method in base/handlers.py:537 only calls super().check_xsrf_cookie() (Tornado's
XSRF validation) without first checking if the request origin is allowed. This allows attackers to:
Risk Assessment: