Revert "Allow staticfiles to follow symlinks outside directory"#1681
Revert "Allow staticfiles to follow symlinks outside directory"#1681
Conversation
Kludex
commented
Jun 10, 2022
- Reverts Allow staticfiles to follow symlinks outside directory #1377
This reverts commit d3dccdc.
|
Ok. The incident has been resolved. It's time to explain what happened. DescriptionLast night, we received a message on Gitter asking for a secure communication channel to report a security issue (much appreciated btw). I sent a message to that person, with @tomchristie in cc. Promptly, they replied with the following message: There was also an application to reproduce the issue attached: import uvicorn
from starlette.applications import Starlette
from starlette.routing import Mount
from starlette.staticfiles import StaticFiles
app = Starlette(
routes=[
Mount('/static', app=StaticFiles(directory='static')),
]
)
if __name__ == '__main__':
uvicorn.run('main:app')As mentioned, the problem was that we were allowing any symlink outside the specified directory from How this happened? How to avoid it in the future?There were three reviewers on the PR that introduced the security issue, and two approvals (mine included). Even with that, we failed to see the issue. As a self evaluation, and retrospective, I think this incident could have been avoided if we either had paid more attention, or maybe don't being overconfident about our knowledge on the What we did to solve the issue?As soon as the report was received, we reverted the PR, created a new release, and "yanked" the previous one on PyPI. The version 0.20.2 was live for less than three days. It's also good to mention that none of the FastAPI users were affected. Lessons learned
Notes:
EDIT: As @m1ckey said some words below, I guess I can now give the merits to him. Thanks so much @m1ckey! ❤️ 🏆 |
|
Thanks a lot for doing this, the quick response, and the full report! |
|
Thank you for the professional handling. |
