in reply to prevent arbitrary code execution in images
1) Prevent them from being executed by the web server. That's just a question of putting the files in a directory where you didn't allow execution of scripts. Limit the files you accept to those with a file name matching /\.(?:jpe?g|gif|png)$/i. Don't use the name provided by the user when saving the image; use a number or something.
2) Prevent them from being executed by the client. Enforce the extention as mentioned above. Try loading the upload in an image info package. (Perhaps ImageMagick or Image-Info?) If the package doesn't recognize the upload as an image, and if it's not a JPEG, GIF or PNG, reject the upload.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: prevent arbitrary code execution in images
by FoxtrotUniform (Prior) on Sep 15, 2004 at 23:11 UTC | |
by ikegami (Patriarch) on Sep 15, 2004 at 23:26 UTC | |
by FoxtrotUniform (Prior) on Sep 15, 2004 at 23:33 UTC | |
by pingo (Hermit) on Sep 16, 2004 at 10:09 UTC | |
by paulbort (Hermit) on Sep 16, 2004 at 23:48 UTC | |
by PodMaster (Abbot) on Sep 16, 2004 at 02:30 UTC | |
by graff (Chancellor) on Sep 16, 2004 at 03:19 UTC |