-
Notifications
You must be signed in to change notification settings - Fork 338
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
[fix] Serve files linked into the static files directory #3108
Conversation
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.
Looks good! Thanks for the contribution @martenlienen 🚀
Waiting for @mihran113's review.
93ca1c0
to
12c6a92
Compare
I force-pushed to fix the style issue. |
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.
Looks good to me! @martenlienen can I ask you to add an entry in CHANGELOG.md
file
In certain conda environments, the files in the static files root directory can be symlinked from a different place. The fixed implementation only resolves relative .. segments in the request path without resolving any symlinks. This way, it still prevents reading arbitrary files through the web server while allowing the reading of symlinked files.
12c6a92
to
8470774
Compare
Done! |
Hey, I think this PR actually resulted in a 404 for all static files served from https://github.com/aimhubio/aim/blob/main/aim/web/api/views.py#L24-L25 if common_prefix == static_files_root:
raise HTTPException(status_code=404) However, note that it would make the code vulnerable to a trivial path traversal: |
Hey @geraldino2! Thanks a lot for noticing the wrong condition!
this line of the code will resolve any |
Hey @mihran113, you are right about path traversal. I didn't really read the code and I guess I may have removed the condition when debugging it. Sorry about that! |
In certain conda environments, the files in the static files root directory can be symlinked from a different place. The fixed implementation only resolves relative .. segments in the request path without resolving any symlinks. This way, it still prevents reading arbitrary files through the web server while allowing the reading of symlinked files.