php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Sec Bug #61883 getimagesize() Denial of Service by excessive memory usage
Submitted: 2012-05-01 00:06 UTC Modified: 2013-02-18 00:35 UTC
From: kobrasrealm at gmail dot com Assigned:
Status: No Feedback Package: GetImageSize related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-05-01 00:06 UTC] kobrasrealm at gmail dot com
Description:
------------
From http://1337day.com/exploits/18161 >>
PHP 5.4.1 getimagesize() Denial of Service Memory leak

Details:

Getimagesize function is used to determine the size of an image. It recives
one parameter as URI. Getimagesize() doesn't implement any function to
verify if the remote file that is been downloaded is an image nor if the
size is higher than desired, so it could be possible to force the PHP
engine to download (through Getimagesize()) a huge file, causing a DoS (in
RAM and CPU) in the webserver.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-05-01 00:07 UTC] kobrasrealm at gmail dot com
-Status: Open +Status: Closed
 [2012-05-01 00:10 UTC] felipe@php.net
-Status: Closed +Status: Re-Opened -Type: Documentation Problem +Type: Security -Package: Website problem +Package: GetImageSize related -Private report: No +Private report: Yes
 [2012-05-01 00:12 UTC] felipe@php.net
-Summary: Missing info +Summary: getimagesize() Denial of Service Memory leak
 [2012-05-01 00:16 UTC] stas@php.net
I do not see any indication of memory leak here. Is the bug that getimagesize() 
loads the image into memory or that it does not free it afterwards? If the 
former, it is not a memory leak.
 [2012-05-01 17:42 UTC] rasmus@php.net
Plus getimagesize() doesn't download the whole file. It first calls 
php_getimagetype() which reads just the first few bytes to get the type of image. 
Then based on that type it will call a function like php_handle_jpeg() which just 
reads the image info. I suppose there might be a way to get that function to read 
forever by crafting a bogus image header somehow, but that would be a different 
bug. The way this bug is reported it seems to assume we load the entire remote 
file into memory in order to check the size, and that simply isn't true.
 [2012-05-01 19:01 UTC] stas@php.net
-Summary: getimagesize() Denial of Service Memory leak +Summary: getimagesize() Denial of Service by excessive memory usage
 [2012-05-01 19:01 UTC] stas@php.net
-Status: Re-Opened +Status: Open
 [2012-05-02 08:21 UTC] pajoye@php.net
I do not see the problem either. Also please keep in mind that remote URI can be 
disabled system wild using php.ini.

Please show a simple script with a sample image to reproduce the issue. Whether 
it is remotely loaded or not should not be relevant here (except for the size of 
the read buffer).

Btw, some typos in your text:

recives > receives
 [2012-05-02 08:21 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2013-02-18 00:35 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 17:01:24 2019 UTC