LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-03-2016, 04:20 AM   #1
danjde
Member
 
Registered: Jun 2014
Posts: 36

Rep: Reputation: Disabled
Exclamation PHP code injection on exif data


Hi friends,
as described here
seem that malicious script can be stored on exif data and so make any problems to own web server image files.

Do you know if is it possible to scan directory and subdirectory for searching bad and dangerous images exif data?


Many thanks!
 
Old 11-05-2016, 04:45 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by danjde View Post
malicious script can be stored on exif data
Please note the EXIF entry is just a text string in an otherwise inert file.


Quote:
Originally Posted by danjde View Post
and so make any problems to own web server image files.
It isn't really "malicious code" until it can be exploited by either PHP-related or client code that misinterprets EXIF data.


Quote:
Originally Posted by danjde View Post
Do you know if is it possible to scan directory and subdirectory for searching
Very crude example to illustrate a simple file search:
Code:
find /path/to/directory -type f -printf "%p\n" | while read ITEM; do file -i "${ITEM}" | grep -q -m1 ':.image/jpeg;' \
&& { echo "# ${ITEM}:"; cat "${ITEM}" | exiftool - | egrep -aie "(\(|\)|\[|\]|\+|\;|\=|\")"; echo ; }; done

Quote:
Originally Posted by danjde View Post
bad and dangerous images exif data?
The problem is that if you run the above on a directory containing images you'll get a lot of False Positives because there's nothing in between to determine if the contents of a string is malicious or not. So the easiest best way is to remove all EXIF data if you're sure your software doesn't require it.
 
Old 11-05-2016, 10:50 AM   #3
danjde
Member
 
Registered: Jun 2014
Posts: 36

Original Poster
Rep: Reputation: Disabled
Waw!! Very clear explanation whit useful code example! ;-)

Quote:
Originally Posted by unSpawn View Post
[..] So the easiest best way is to remove all EXIF data if you're sure your software doesn't require it.
About this point, what do you think about traditional cms systems and its gallery applications about exif data?
Could be useful delete all its images exif data? I think this could generate another kind of problems.

And so, ideally, we should be able to delete only "extra exif data". But how mark "extra" certain types of exif data?

..mumble ..mumble.. :-)
 
Old 11-05-2016, 09:51 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by danjde View Post
what do you think about traditional cms systems and its gallery applications about exif data?
I don't know much about "traditional" CMSes (and for deities sake let's not discuss the ones calling themselves "modern" ;-p) but in general EXIF data gets inserted by the device so by default you should get something like device vendor, image resolution, date and time, location etcetera. (That doesn't mean you can't add ownership, copyleft and such.) Most common usage for plain old web logs and e-commerce CMSes would be to use EXIF data to say rotate a picture so it displays correctly and that's about it (check the documentation).


Quote:
Originally Posted by danjde View Post
Could be useful delete all its images exif data? I think this could generate another kind of problems.
Like what for example? Either way CMS / plugin documentation should show what's required?


Quote:
Originally Posted by danjde View Post
And so, ideally, we should be able to delete only "extra exif data". But how mark "extra" certain types of exif data?
The problem isn't in certain "extra" types but 0) that any EXIF, IPTC (and XMP) data fields are just strings that can be manipulated by exif, exiftool and other editors and 1) that rule #1 (or #0, should you wish to count properly ;-p) of safe coding is to not ever trust user-supplied input.
 
  


Reply

Tags
exif, malicious, php



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading exif data from a C program billsee Programming 6 07-19-2016 09:11 PM
Reading EXIF data billsee Linux - Software 4 09-09-2014 12:17 AM
bash code to recursively remove EXIF info leosgb Programming 4 10-25-2007 12:31 AM
Change Exif data in linux? shwouchk Linux - Software 2 12-02-2006 06:31 AM
POST data to PHP code ckoniecny Programming 6 03-02-2006 10:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration