Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External image vulnerabilities

What security holes can appear on my site by including external images via img tag and how to avoid them?

I'm currently only checking the extension and mime-type of image on submission (that can be changed after URL is submitted) and URL is sanitized before putting it in src attribute.

like image 314
Noobie Avatar asked Jul 21 '12 22:07

Noobie


2 Answers

There's probably a differentiation to be made here between who is at risk.

If all you're doing is storing URLs, and not uploading images to your server, then your site is probably safe, and any potential risk is to your users who view your site.

In essence, you're putting your trust in the reliability of the browser manufacturers. Things might be fine, but if a security hole in some browser one of your users uses were to arise that involved incorrectly parsing images that contain malicious code, then it's your users who will end up paying for it (you might find GIFAR interesting).

It comes down to whether you trust the browser manufacturers to make secure software, and whether you trust your users to not upload URLs to images that might contain exploits for certain browsers. What might be secure now might not be secure come the next release.

like image 162
Rhys Avatar answered Sep 30 '22 15:09

Rhys


The primary holes that can be exposed are those where corrupted images cause buffer overflows within the browser, allowing arbitrary code execution.

If you're only putting the images into an <img> tag there shoudln't be any vulnerabilities relating to sending alternative MIME types, but never underestimate the stupidity of some web browser developers...

like image 38
Alnitak Avatar answered Sep 30 '22 14:09

Alnitak