# Security checks on uploads

**URL:** <https://meta.discourse.org/t/security-checks-on-uploads/26839>\
**Category:** Product Support\
**Created:** [26 مارس 2015، 7:05م UTC](https://meta.discourse.org/t/security-checks-on-uploads/26839 "2015-03-26T19:05:11Z")\
**Posts on this page:** 1\
**Showing post:** 31

<div class="post-metadata">

**Author:** ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)\
**Post date:** [1 أبريل 2015، 12:27ص UTC](https://meta.discourse.org/t/security-checks-on-uploads/26839/31 "2015-04-01T00:27:05Z")

</div>

Well, let’s give it a whirl:

1. Following the instructions at [http://marcoramilli.blogspot.de/2014/01/hacking-through-image-gif-turn.html](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](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](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:

 ![](https://global.discourse-cdn.com/meta/original/3X/f/5/f56e6de2af55bfca363572abefabe57c3764a27e.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.)

---

_[View the full topic](https://meta.discourse.org/t/security-checks-on-uploads/26839)._
