Vulnerability Note VU#929115

PHP fails to properly parse the headers of HTTP POST requests

Original Release date: 22 Jul 2002 | Last revised: 30 May 2003

Overview

A vulnerability has been discovered in PHP. This vulnerability could be used by a remote attacker to execute arbitrary code or crash PHP and/or the web server.

Description

PHP is a popular scripting language in widespread use. For more information about PHP, see http://www.php.net/manual/en/faq.general.php.

The vulnerability occurs in the portion of PHP code responsible for handling file uploads, specifically multipart/form-data. By sending a specially crafted POST request to the web server, an attacker can corrupt the internal data structures used by PHP. Specifically, an intruder can cause an improperly initialized memory structure to be freed. In most cases, an intruder can use this flaw to crash PHP or the web server. Under some circumstances, an intruder may be able to take advantage of this flaw to execute arbitrary code with the privileges of the web server.

You may be aware that freeing memory at inappropriate times in some implementations of malloc and free does not usually result in the execution of arbitrary code. However, because PHP utilizes its own memory management system, the implementation of malloc and free is irrelevant to this problem.

Stefan Esser of e-matters GmbH has indicated that intruders cannot execute code on x86 systems. However, we encourage system administrators to apply patches on x86 systems as well to guard against denial-of-service attacks and as-yet-unknown attack techniques that may permit the execution of code on x86 architectures.

This vulnerability was discovered by e-matters GmbH and is described in detail in their advisory. The PHP Group has also issued an advisory. A list of vendors contacted by the CERT/CC and their status regarding this vulnerability is available in VU#929115.

Although this vulnerability only affects PHP 4.2.0 and 4.2.1, e-matters GmbH has previously identified vulnerabilities in older versions of PHP. If you are running older versions of PHP, we encourage you to review http://security.e-matters.de/advisories/012002.html.

Impact

A remote attacker can execute arbitrary code on a vulnerable system. An attacker may not be able to execute code on x86 architectures due to the way the stack is structured. However, an attacker can leverage this vulnerability to crash PHP and/or the web server running on an x86 architecture.

Solution

Apply a patch from your vendor

Appendix A contains information provided by vendors for this advisory. As vendors report new information to the CERT/CC, we will update this section and note the changes in our revision history. If a particular vendor is not listed below, we have not received their comments. Please contact your vendor directly.

Upgrade to the latest version of PHP

If a patch is not available from your vendor, upgrade to version 4.2.2.

Deny POST requests

Until patches or an update can be applied, you may wish to deny POST requests. The following workaround is taken from the PHP Security Advisory:

      If the PHP applications on an affected web server do not rely on HTTP POST input from user agents, it is often possible to deny POST requests on the web server.

      In the Apache web server, for example, this is possible with the following code included in the main configuration file or a top-level .htaccess file:

      <Limit POST>
         Order deny,allow
         Deny from all
      </Limit>

      Note that an existing configuration and/or .htaccess file may have parameters contradicting the example given above.

Disable vulnerable service

Until you can upgrade or apply patches, you may wish to disable PHP. As a best practice, the CERT/CC recommends disabling all services that are not explicitly required. Before deciding to disable PHP, carefully consider your service requirements.

Systems Affected (Learn More)

VendorStatusDate NotifiedDate Updated
DebianAffected22 Jul 200222 Jul 2002
FreeBSDAffected22 Jul 200222 Jul 2002
MandrakeSoftAffected22 Jul 200222 Jul 2002
PHP Development TeamAffected-22 Jul 2002
Apple Computer Inc.Not Affected22 Jul 200222 Jul 2002
ConectivaNot Affected-23 Jul 2002
Cray Inc.Not Affected22 Jul 200222 Jul 2002
F5 NetworksNot Affected22 Jul 200223 Jul 2002
Guardian Digital Inc. Not Affected-22 Jul 2002
Hewlett-Packard CompanyNot Affected22 Jul 200225 Jul 2002
IBMNot Affected22 Jul 200222 Jul 2002
Microsoft CorporationNot Affected22 Jul 200222 Jul 2002
Network ApplianceNot Affected22 Jul 200222 Jul 2002
Red Hat Inc.Not Affected22 Jul 200222 Jul 2002
SuSE Inc.Not Affected22 Jul 200222 Jul 2002
If you are a vendor and your product is affected, let us know.View More »

CVSS Metrics (Learn More)

Group Score Vector
Base N/A N/A
Temporal N/A N/A
Environmental N/A N/A

References

Credit

Thanks to e-matters Security for reporting this vulnerability.

This document was written by Ian A Finlay.

Other Information

  • CVE IDs: CAN-2002-0717
  • CERT Advisory: CA-2002-21
  • Date Public: 22 Jul 2002
  • Date First Published: 22 Jul 2002
  • Date Last Updated: 30 May 2003
  • Severity Metric: 42.53
  • Document Revision: 35

Feedback

If you have feedback, comments, or additional information about this vulnerability, please send us email.