Security checks on uploads

Well, let’s give it a whirl:

  1. Following the instructions at http://marcoramilli.blogspot.de/2014/01/hacking-through-image-gif-turn.html, I’ve created a GIF with an embedded JavaScript.
  2. The created file is available here: http://www.elberet.de/~jens/image.gif_malw.gif.zip
  3. Uploaded the file to Discourse: https://meta.discourse.org//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/f/5/f56e6de2af55bfca363572abefabe57c3764a27e.gif
  4. Hit F12 and run document.write("<script src=\"https://url.to/original.gif\" type=\"text/javascript\"></script>"); and you get a JavaScript alert.
  5. Now run document.write("<script src=\"https://meta.discourse.org//cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/f/5/f56e6de2af55bfca363572abefabe57c3764a27e.gif\" type=\"text/javascript\"></script>");… and it doesn’t work anymore.

Discourse postprocesses all uploaded images (as far as I’ve understood the OptimizedImage code). All files you’re going to download from Discourse will be valid images, even if the image data they contain is visual garbage.

I would be far more concerned about legal repercussions for hosting criminal material than serving malware…

(Oh, and it still works as a GIF:

… at least sort of. I probably shouldn’t have used an animated GIF, the detected dimensions are out of whack so it gets lightboxed.)