Skip to content
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

/utilities/upload can modify the requested filename (Very problematic 😅) #191

Open
chrisjsewell opened this issue Jun 28, 2023 · 3 comments

Comments

@chrisjsewell
Copy link
Contributor

During the upload operation, a function secure_filename is applied to the filename:

filename = secure_filename(file.filename)

(this function: https://github.com/pallets/werkzeug/blob/417268cb0ff2ecf8da29f80d542b0b10c97bab01/src/werkzeug/utils.py#L194)

This is really problematic because, among other things, it will strip _ and . from the ends of the filename.
In AiiDA, for example, we use _aiidasubmit.sh for all SLURM submission scripts, which now gets copied as aiidasubmit.sh, and thus everything fails because it cannot find the file 😭

Obviously, I can understand if you want to have security checks, but especially stripping _ seems very unnecessary?

I would probably expect at least that the upload simply failed, if the "secure" filename was different from the original filename, otherwise it leads to very unexpected (and difficult to debug) outcomes

@chrisjsewell
Copy link
Contributor Author

Note there was an issue opened on this _ stripping, but its not very informative 🤷 : pallets/werkzeug#1398

@chrisjsewell
Copy link
Contributor Author

chrisjsewell commented Jun 29, 2023

Note also, this secure_filename function is used in a few other places

@khsrali
Copy link

khsrali commented Jul 31, 2024

Just for the record:
this wired 😄 issue is fixed now. I think we can close here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants