|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2016-12-14 10:15 UTC] eyal dot itkin at gmail dot com
 Description: ------------ In the ext\exif\exif.c function there are general parsing methods, for parsing according to a format: * exif_convert_any_format * exif_convert_any_to_int When these function are used to parse TIFF and JPEG tags from a malicious file, they can lead to an exception in intel chipsets. The targeted formats are: * TAG_FMT_URATIONAL * TAG_FMT_SRATIONAL This is since intel raise an exception in division by zero (checked) and in another division exception (see link: http://x86.renejeschke.de/html/file_module_x86_id_72.html): MIN_INT / -1 ==> divide error exception These corner cases should be added to ensure the PHP program won't terminate. Test script: --------------- No script is needed, only a TIFF/JPEG file, and it is somewhat unneeded. The use of the generic functions is quite straightforward, and so does intel's instructions regarding the DIV command. Patchesnew (last revision 2017-04-08 10:06 UTC by 20february2016 at gmail dot com)Pull Requests
Pull requests: 
 HistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
Here is the PHP script that reproduces the crash on the 1st function, as I mentioned in my previous comment: <?php $e = exif_thumbnail("example_hostile.exif"); echo "Loaded the exif picture\n"; ?> And here is the trace: Program terminated with signal SIGFPE, Arithmetic exception. #0 0xb4fd9d74 in ?? () from /usr/lib/php/20151012/exif.so (gdb) bt #0 0xb4fd9d74 in ?? () from /usr/lib/php/20151012/exif.so #1 0xb4fdb11f in ?? () from /usr/lib/php/20151012/exif.so #2 0xb4fdbd40 in ?? () from /usr/lib/php/20151012/exif.so #3 0xb4fdbc11 in ?? () from /usr/lib/php/20151012/exif.so #4 0xb4fdc134 in ?? () from /usr/lib/php/20151012/exif.so #5 0xb4fdc886 in zif_exif_thumbnail () from /usr/lib/php/20151012/exif.so #6 0x802f8662 in execute_internal () #7 0x80251dce in dtrace_execute_internal () #8 0x802e9f65 in ?? () #9 0x802a26da in execute_ex () #10 0x80251c35 in dtrace_execute_ex () #11 0x802fa1b6 in zend_execute () #12 0x8026210d in zend_execute_scripts () #13 0x80201054 in php_execute_script () #14 0x802fc01f in ?? () #15 0x800db64f in main () (gdb) info reg eax 0x80000000 -2147483648 ecx 0x1 1 edx 0xffffffff -1 ebx 0x0 0 esp 0xbff4c188 0xbff4c188 ebp 0xb525d302 0xb525d302 esi 0xb525d30a -1255812342 edi 0xffffffff -1 eip 0xb4fd9d74 0xb4fd9d74 eflags 0x210202 [ IF RF ID ] cs 0x73 115 ss 0x7b 123 ds 0x7b 123 es 0x7b 123 fs 0x0 0 gs 0x33 51 One can see that the registers involved are edx (-1) and eax (MIN_INT), as intel describes in their chipset specs. The .exif file that reproduces this crash can be found in this link: http://www.cs.tau.ac.il/~eyalitki/Upload/73737/