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

Lack of magic byte file type detection / ImageTragick mitigation #443

Open
bdewater opened this issue Jun 1, 2016 · 3 comments
Open

Lack of magic byte file type detection / ImageTragick mitigation #443

bdewater opened this issue Jun 1, 2016 · 3 comments

Comments

@bdewater
Copy link

bdewater commented Jun 1, 2016

I'm currently evaluating different file upload solutions for Rails and as far as I can tell Dragonfly solely relies on the file extension to identify the content type of files. Given the recent ImageTragick vulnerability (CVE-2016–3714) we're reminded that blindly trusting user input/files and passing it along for processing is a bad thing. Benign use cases like #386 and #434 would also benefit from from getting the correct mime type by inspecting magic bytes before doing anything with it.

The code has an example for #shell_eval of using the file command, but it is only used for the also vulnerable identify command in the ImageMagick plugin.

Some references on how other libraries dealt with similar issues:

@markevans
Copy link
Owner

hi there - thanks for the heads up - yes, this is something that needs looking into. it actually used to use the file command automatically but that incurred other problems (maybe because of the way it was implemented). I'll try to come back to this in the next week or so (I'm incredibly busy over the next few days)

@bdewater
Copy link
Author

bdewater commented Jun 1, 2016

Hi Mark, thanks for your reply and your work on this gem. I've dug in the history and it was removed in 4b0a43e although the commit message doesn't mention any problems it would have caused.

Those other two gems use the #by_magic method from https://github.com/minad/mimemagic which is probably less prone to edge cases than calling shell commands. Paperclip uses file as a fallback.

@nicops
Copy link

nicops commented Jun 3, 2016

In our project we patched this vulnerability by tweaking ImageMagick directly... do you think that doesn't suffice, or it's just a paranoid check to avoid generating more vectors of attack?

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

3 participants