This has been done in the past. I remember seeing an advisory as far back as 2010, but at the moment can only find these two more recent advisories:
https://websec.io/2012/09/05/A-Silent-Threat-PHP-in-EXIF.htm...
https://blog.sucuri.net/2013/07/malware-hidden-inside-jpg-ex...
The way we protected ourselves against it at <earlier company> (since we allowed image uploads at a variety of locations) was to decode and recode the image before storing and strip out comments.
Re:This JPEG is also a webpage
by 45h34jh53k4j on Wednesday August 10, 2016 @03:09PM
(#12264106)
I agree transcoding all user content is a must, but even that can be dangerous :-) as with ImageTragick which lcamtuf discussed here: https://lcamtuf.blogspot.com/2016/05/clearing-up-some-miscon...
now specifically in this case, lcamtuf (at google security) is joking and doesn't want your money.
this hack is actually pretty crazy - an arbitrary HTML / jpeg polyglot file that fooled a browser could be used for js injection, say from a site that allowed jpeg file uploads, and validated mime type.