|
|
|
|
|
by metalrain
326 days ago
|
|
So can you construct valid image that would also act as zip bomb? Jpeg and other lossy compression images should allow some of that, but dependens on compatibility of compression between gzip and image format. There is that example where you have "zero image" of big dimensions, but can you actually conflate gzip and image compression? |
|
I consulted for a bank once where the server stripped metadata and re-encoded images from scratch again and the devs thought that would remove any maliciousness. It's just pixels right? I might have thought so as well, but I had this idea and wanted to double check, and it didn't take long to find someone smarter than me had already done the work: https://web.archive.org/web/20250713054441/http://www.idontp... (By now I see there are a dozen commercial parties that rank higher for this topic. Marginalia search helped me re-find the OG post just now)
Edit, thought I should add: the solution is to specify the correct content type. Don't let your PHP interpreter interpret files in the user uploads directory. Don't serve images with content-type text/html because the browser will interpret it as HTML (as instructed) and run any code inside on your domain ('origin'). Mark data as separate from code whenever possible, or escape it when that's impossible