A recent bug in Android allows a hacker to execute code that is contained within an image file. Here is the quote from the Android Security Bulletin,
The most severe vulnerability in this section could enable a remote attacker using a specially crafted PNG file to execute arbitrary code within the context of a privileged process
From a somewhat related question which asks about a code within pdf,
If a file name has the word "exe" somewhere within, has not bearing on what file type it is, and it does not change how the operating system would handle that file. If file identification tools says this is a pdf, it probably is a pdf.
That said, pdf files can theoretically be crafted to exploiting bugs in pdf > readers.
What I understand is that an OS will not execute a code within a file if it is not a executable type. Any application handling file may execute the code. In this bug the OS itself executes code from a non-executable file type.
So how is the code in the PNG file getting executed by the OS?