Problem:
I am working on an internal tool that allows users to upload images - and then displays these images to them and others.
This is a Java / Spring application. I only need to worry about IE11 for sure and Firefox v38 + (Chrome v43 + would be nice to have)
After the first development of the function, it seems that users can simply create a text file, for example:
<script>alert("malicious code here!")</script>
and save it as "maliciousImage.jpg" and load it.
Later, when this image is displayed inside the image tags, for example:
<img src="blah?imgName=foobar" id="someImageID">
actualImage.jpg is displayed normally, and maliciousImage.jpg is displayed as a broken link - and, most importantly, no malicious content is interpreted!
, " "... .
"-" , , "maliciousImage.jpg" HTML . script JavaScript , , .
,
, , , . , , stackoverflow , , , X- IE.
x-content- , . , , , .
response.setHeader("X-Content-Type-Options", "nosniff");
response.setContentType("image/jpg");
, , , , , ...
, , , ...
:
- , ( , ..), , HTML/javascript , HTML /CDATA'- ... , , .