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

Handling invalid file names in multipart middleware #342

Open
expez opened this issue Aug 21, 2018 · 1 comment
Open

Handling invalid file names in multipart middleware #342

expez opened this issue Aug 21, 2018 · 1 comment
Labels

Comments

@expez
Copy link
Contributor

expez commented Aug 21, 2018

I just spotted this stracktrace in our logs, as someone tried to mess with our servers:

  	org.apache.commons.fileupload.InvalidFileNameException: Invalid file name: DwldYyIuSimpleASP6qrV.asp\0.svg
	at org.apache.commons.fileupload.util.Streams.checkFileName(Streams.java:189) ~[acme-1.56.33-standalone.jar:na]
	at org.apache.commons.fileupload.FileUploadBase$FileItemIteratorImpl$FileItemStreamImpl.getName(FileUploadBase.java:829) ~[acme-1.56.33-standalone.jar:na]
	at ring.middleware.multipart_params$parse_file_item.invokeStatic(multipart_params.clj:86) ~[acme-1.56.33-standalone.jar:na]

I'd prefer returning a 400 response, with a message about an invalid filename, but I can't see a way to do that, so this results in a 500 catch-all response. Am I missing something?

If not, would you welcome a PR?

@weavejester
Copy link
Member

You can wrap the middleware in other middleware that catches that specific exception, but you're right that it should result in a 400 error rather than a 500 error. A PR would be welcome.

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

No branches or pull requests

2 participants