|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kobrasrealm at gmail dot com
New email:
PHP Version: OS:


 [2012-05-01 00:06 UTC] kobrasrealm at gmail dot com
From >>
PHP 5.4.1 getimagesize() Denial of Service Memory leak


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.


Add a Patch

Pull Requests

Add a Pull Request


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]
-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]
-Summary: Missing info +Summary: getimagesize() Denial of Service Memory leak
 [2012-05-01 00:16 UTC]
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]
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]
-Summary: getimagesize() Denial of Service Memory leak +Summary: getimagesize() Denial of Service by excessive memory usage
 [2012-05-01 19:01 UTC]
-Status: Re-Opened +Status: Open
 [2012-05-02 08:21 UTC]
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]
-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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC