Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 45971 - PHP openlog() Buffer Overflow Vulnerability
Summary: PHP openlog() Buffer Overflow Vulnerability
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Security
URL: http://http://www.securityfocus.com/b...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-28 04:03 UTC by schaedpq
Modified: 2011-10-30 22:41 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description schaedpq 2004-03-28 04:03:40 UTC
A buffer overflow has been reported in the PHP openlog() function. By passing an argument of excessive size to the function, it may be possible for an attacker to overwrite memory, resulting in a denial of service or (unconfirmed) possible execution arbitrary commands within the PHP interpreter.

Reproducible: Didn't try
Steps to Reproduce:
1.
2.
3.




Information taken from Bugtraq:
http://www.securityfocus.com/bid/7210/discussion/
The vulnerability was reported for php 4.3.1 and later. Bugtraq states that it
is likely that previous versions are affected.
Link to original post on bugtraq: http://www.securityfocus.com/archive/1/316488
Proof of concept exploit has been published.

Temporary (unofficial and unconfirmed) workaround is to disable the openlog
function:
http://www.securityfocus.com/archive/1/316583

I think there is no fixed version of php because I cannot find anything in
respect to openlog in the changelog of php4 or php5, also bugtraq contains no
hint to fixed version/patch.
I searched the php website for some information on this bug but found nothing.
Therefore I believe, that the vulnerability is also in php 4.3.4 (latest stable
in portage), especially since php-5rc1 (released on 18 Mar 2004) is still affected.

I hope that I didn't overlook something (bugfix, patch,...).
Comment 1 Kurt Lieber (RETIRED) gentoo-dev 2004-03-28 04:35:15 UTC
PHP herd -- could you review/comment?
Comment 2 Stuart Herbert (RETIRED) gentoo-dev 2004-03-28 11:18:34 UTC
Looking now ...
Comment 3 Stuart Herbert (RETIRED) gentoo-dev 2004-03-28 13:06:06 UTC
Here's what I've looked at so far:

* The syslog.c source code file hasn't been touched since January 2004, and no fixes for any bug like this have been committed since php-4.3.1 was released.
* I can't reproduce the buffer overflow issue.  I've loaded a copy of php-4.3.4 with debugging statements, and I can't see any problem.  And I can't spot an obvious problem from reviewing the code either.  The key part of the openlog() function comes down to a call to estrndup():

ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
        char *p;

        HANDLE_BLOCK_INTERRUPTIONS();
        p = (char *) _emalloc(length+1 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
        if (!p) {
                HANDLE_UNBLOCK_INTERRUPTIONS();
                return (char *)NULL;
        }
        HANDLE_UNBLOCK_INTERRUPTIONS();
        memcpy(p, s, length);
        p[length] = 0;
        return p;
}

This function is used throughout PHP for duplicating strings.  If openlog() was vulnerable, then there would be many other exploits also possible.

If you have code that reproduces this fault, please add it to this bug.  The script included in one of the links below does not show up this security hole.

Best regards,
Stu
Comment 4 Kurt Lieber (RETIRED) gentoo-dev 2004-04-08 07:45:50 UTC
No response from submitter in ~1 week. Since we were unable to reproduce this bug locally and have not had further contact from the original submitter, closing as invalid.