CVE detail

CVE-2007-3205

PHP parse_str Function Vulnerable to Variable Overwrite Attacks

MediumModified
CVSS5.0
EPSS
Exploitability7
Exploit refs0

Summary

CVE-2007-3205 is a medium-severity vulnerability in PHP's `parse_str` function that, when called without a second parameter, allows remote attackers to overwrite arbitrary variables via crafted input. This affects PHP, Hardened-PHP, and Suhosin, and can lead to variable injection and potential code execution.

Published

Jun 13, 2007

Last modified

Jun 17, 2026

CWE

NVD-CWE-Other · Not Applicable

Affected product

cpe:2.3:a:hardened-php_project:hardened-php:*:*:*:*:*:*:*:* cpe:2.3:a:hardened-php_project:subhosin:*:*:*:*:*:*:*:* cpe:2.3:a:php:php:*:*:*:*:*:*:*:*

Why exploitable

Why Exploitable

The parse_str function vulnerability in PHP, Hardened-PHP, and Suhosin allows remote attackers to overwrite arbitrary variables. This is likely due to a bug in these implementations.

  • Empirical exploitation probability (EPSS) is not available for this CVE, making it difficult to assess the likelihood of exploitation.
  • The absence of public exploit listings and the fact that it's not in the CISA KEV list reduce the urgency to patch.
  • However, organizations should still validate their PHP, Hardened-PHP, and Suhosin versions and consider updating to patched versions to prevent potential attacks. Key considerations include reviewing code that uses the parse_str function and ensuring it is called with a second parameter to prevent variable overwrites.

Technical details

Overview

CVE-2007-3205 is a vulnerability in the parse_str function of PHP, as well as in Hardened-PHP and Suhosin extensions. The issue arises when parse_str is called without a second parameter, allowing an attacker to overwrite arbitrary variables by specifying variable names and values in the input string. This can lead to variable injection, potentially enabling further attacks such as remote code execution or privilege escalation. The vulnerability has a CVSS base score of 5 (Medium) and an EPSS percentile of 79.1, indicating a relatively high probability of exploitation in the wild. Affected technologies include PHP versions prior to the fix, as well as Hardened-PHP and Suhosin implementations. The disclosure timeline is not specified, but the vulnerability was publicly reported and assigned CVE-2007-3205. Defenders should prioritize patching PHP installations and reviewing code that uses parse_str without a second parameter.

Technical details

The root cause of CVE-2007-3205 is the behavior of PHP's parse_str function when called with only one argument. The function parses a query string into variables in the current scope. Without a second parameter (an array to store the parsed variables), the function directly overwrites existing variables in the symbol table. This allows an attacker to control the values of variables that may be used in security-sensitive operations, such as authentication checks, file inclusion, or command execution. The vulnerability is classified under CWE-Other (Not Applicable), but it is essentially a form of variable injection or dynamic variable evaluation. Attack prerequisites include the ability to supply a string to parse_str via user input (e.g., HTTP query string, POST data, or other input vectors). The trust boundary is crossed when untrusted input is passed to parse_str without proper sanitization or the use of a second parameter. Affected versions include PHP 4.x and 5.x prior to the fix, as well as Hardened-PHP and Suhosin patches that did not address this behavior.

Impact

Successful exploitation of CVE-2007-3205 can lead to variable overwrite, which may result in:

  • Confidentiality: An attacker could overwrite variables that control access to sensitive data, potentially leading to information disclosure.
  • Integrity: Overwriting variables used in security checks (e.g., $is_admin) could allow privilege escalation or bypass of authentication.
  • Availability: In some cases, variable injection could lead to denial of service by causing unexpected behavior or crashes. Downstream abuse scenarios include remote code execution if the overwritten variable is used in an include() or eval() statement. Business exposure includes potential data breaches, unauthorized access, and reputational damage. Defenders should assess the use of parse_str in their codebase and ensure it is called with a second parameter to mitigate this risk.

Exploitation steps

  1. Identify a PHP application that calls parse_str() with only one argument (e.g., parse_str($input)).
  2. Determine the input vector (e.g., HTTP GET/POST parameter, cookie, or other user-supplied data) that is passed to parse_str.
  3. Craft a malicious string containing variable names and values, such as variable_name=value&another_var=malicious_value.
  4. Send the crafted input to the application, causing parse_str to overwrite the corresponding variables in the current scope.
  5. If the overwritten variable is used in a security-sensitive operation (e.g., if ($is_admin)), the attacker can bypass checks.
  6. Escalate by overwriting variables used in file inclusion or command execution to achieve remote code execution.
  7. Verify successful exploitation by observing the application's behavior (e.g., unauthorized access, error messages, or system commands executed).
  8. Maintain persistence by injecting backdoors or modifying application logic through variable overwrite.

Indicators of compromise

  • Network: Unusual query strings containing variable assignments (e.g., ?var1=value1&var2=value2) that do not match expected application parameters.
  • Logs: PHP error logs showing unexpected variable overwrite warnings or notices related to parse_str.
  • EDR: Processes executing unexpected PHP scripts or commands after variable injection.
  • Behavioral: Unauthorized access to administrative functions or sensitive data without proper authentication.
  • File system: Presence of unexpected files or modifications to application code that could indicate successful exploitation.
  • Memory: Unusual variable values in PHP memory dumps or debug output.
  • Application: Changes in application behavior, such as altered user roles or bypassed security checks.
  • Web server: Access logs showing requests with suspiciously long or structured query strings.

Mitigation and workarounds

  • Patch: Upgrade PHP to a version where parse_str requires a second parameter or has been fixed to prevent variable overwrite. For PHP 5.x, versions 5.2.4 and later include a fix. For PHP 4.x, upgrade to 4.4.8 or later.
  • Code fix: Ensure all calls to parse_str include a second parameter (e.g., parse_str($input, $output_array)). This stores parsed variables in an array and prevents overwriting of existing variables.
  • Compensating controls: If patching is not immediately possible, implement input validation and sanitization for all data passed to parse_str. Use a web application firewall (WAF) to block malicious query strings.
  • Configuration: Disable register_globals in PHP configuration (if still available) to reduce the impact of variable injection.
  • Monitoring: Enable logging of parse_str usage and monitor for unusual variable assignments.

Community reactions

The security community has discussed CVE-2007-3205 as a design flaw in PHP's parse_str function. Some argue that the behavior is intentional for backward compatibility, while others consider it a bug. Hardened-PHP and Suhosin projects have addressed the issue by modifying the function's behavior. The vulnerability is often cited in discussions about PHP security best practices, emphasizing the importance of using the second parameter. References include advisories from PHP.net and security mailing lists.

Additional resources

Intelligence is provided for awareness and triage. Validate exposure in your own environment before prioritising remediation.

CVE-2007-3205 · PHP parse_str Function Vulnerable to Variable Overwrite Attacks | CVE Intelligence | Trusteed