Image Upload Validation Flaws Enable XSS and Cross-Site Content Hijacking
Vulnerability Disclosure · 2 sources · Updated 3mo ago · First seen Sep 18, 2018

Researchers described how weak image-upload controls can let attackers submit files with benign-looking extensions such as .jpg while embedding active content that browsers may execute under the victim site’s origin context. One technique abuses browser content handling with tags such as OBJECT to force interpretation of uploaded content as Flash or other active formats, allowing a malicious file hosted on a trusted site to send authenticated requests with the victim’s cookies and read sensitive responses such as profile data or CSRF tokens. The same class of issue can also support follow-on CSRF-style actions when a logged-in user is lured to an attacker-controlled page.
Separate analysis of web applications using ImageMagick and CarrierWave showed that insecure defaults can widen the exposure by storing uploaded files and temporary cache files in publicly reachable directories, sometimes without reliable access control. The research found that obscure image formats and malformed payloads can trigger browser-side script execution when servers return incorrect or missing Content-Type headers, and that leftover cache files after validation or conversion failures may remain accessible if their URLs are guessable. Recommended defenses include validating file content as well as extensions, restricting accepted formats, serving uploads with correct MIME types, enabling X-Content-Type-Options: nosniff, and moving protected uploads and caches outside public web paths.


