#42222 [NEW]: php_openssl_make_REQ() buffer overflow

From: Date: Mon, 06 Aug 2007 18:10:52 +0000
Subject: #42222 [NEW]: php_openssl_make_REQ() buffer overflow
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115809@lists.php.net to get a copy of this message
From:             zatanzlatan at hotbrev dot com
Operating system: Linux
PHP version:      5CVS-2007-08-06 (CVS)
PHP Bug Type:     Reproducible crash
Bug description:  php_openssl_make_REQ() buffer overflow

Description:
------------
function php_openssl_make_REQ() in ext/openssl/openssl.c has buffer
overflow when parsing openssl.conf

look at this:

			char buffer[200];
			
			v = sk_CONF_VALUE_value(dn_sk, i);
			type = v->name;
			
			len = strlen(type);
			if (len < sizeof("_default")) {
				continue;
			}
			len -= sizeof("_default") - 1;
			if (strcmp("_default", type + len) != 0) {
				continue;
			}
			
			memcpy(buffer, type, len);
			buffer[len] = '\0';

no check if name field with "_default" removed is larger than 200!

if u change "0.organizationName_default" in openssl.conf to "0." + 300
chars + "_default" then the buffer will be overflown in the memcpy().

Reproduce code:
---------------
u can test this with openssl_csr_new().

Expected result:
----------------
program should keep running.

Actual result:
--------------
program crashed.

-- 
Edit bug report at http://bugs.php.net/?id=42222&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42222&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42222&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42222&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42222&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=42222&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42222&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42222&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42222&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42222&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42222&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=42222&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=42222&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42222&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42222&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42222&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42222&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42222&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42222&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42222&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42222&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#115809) next »