VYPR
Unrated severityNVD Advisory· Published Dec 21, 2009· Updated Apr 23, 2026

CVE-2009-4142

CVE-2009-4142

Description

The htmlspecialchars function in PHP before 5.2.12 does not properly handle (1) overlong UTF-8 sequences, (2) invalid Shift_JIS sequences, and (3) invalid EUC-JP sequences, which allows remote attackers to conduct cross-site scripting (XSS) attacks by placing a crafted byte sequence before a special character.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

PHP's htmlspecialchars() before 5.2.12 fails to reject malformed multibyte sequences, enabling XSS injection via crafted byte sequences.

Vulnerability

The htmlspecialchars function in PHP versions before 5.2.12 does not properly validate certain multibyte character encodings. Specifically, it fails to handle (1) overlong UTF-8 sequences, (2) invalid Shift_JIS sequences, and (3) invalid EUC-JP sequences. This allows an attacker to inject a crafted byte sequence before a special character (such as <, >, &, ", or ') that would normally be escaped, potentially bypassing the escaping logic. The vulnerability affects all PHP 5.x releases prior to 5.2.12 [1][4].

Exploitation

An attacker can exploit this vulnerability by supplying a specially crafted input string containing a malformed multibyte sequence that includes a special character. The attacker does not require authentication or any particular network position beyond being able to provide user-controlled input that is processed by htmlspecialchars. For example, placing an overlong UTF-8 sequence before a < character may cause htmlspecialchars to misinterpret the boundary and fail to encode the < as <. The attack can be launched remotely via HTTP parameters or any text input that PHP uses in an output context without further sanitization [2][3].

Impact

Successful exploitation leads to cross-site scripting (XSS), allowing an attacker to inject arbitrary HTML and JavaScript into a web application's output. The attacker can craft payloads that execute in the context of a victim's browser, potentially leading to session theft, credential harvesting, or other malicious actions. The impact is the same as typical stored or reflected XSS, depending on how the input is processed [3].

Mitigation

The vulnerability is fixed in PHP version 5.2.12, released on 17 December 2009 [4]. All users of PHP 5.2.x should upgrade to 5.2.12 or later. For PHP 5.3.x, the fix is included in version 5.3.1 (released alongside). No workarounds are documented. The operating system vendors, such as Apple and HP, released security updates incorporating the fix (e.g., Apple Security Update 2010-002, HP-UX patch) [2][3].

AI Insight generated on May 24, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected products

111
  • PHP/PHP111 versions
    cpe:2.3:a:php:php:*:*:*:*:*:*:*:*+ 110 more
    • cpe:2.3:a:php:php:*:*:*:*:*:*:*:*range: <=5.2.11
    • cpe:2.3:a:php:php:1.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:2.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:2.0b10:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.10:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.11:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.12:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.13:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.14:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.15:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.16:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.17:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.18:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.6:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.7:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.8:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:3.0.9:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.1:patch1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.1:patch2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.3:patch1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.4:patch1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.6:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.7:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.7:rc1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.7:rc2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.7:rc3:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0.7:rc4:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:beta1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:beta2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:beta3:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:beta4:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:beta_4_patch1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:rc1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.0:rc2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.1.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.1.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.1.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.2.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.2.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.2.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.2.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.2:*:dev:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.10:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.11:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.6:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.7:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.8:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.3.9:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.6:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.7:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.8:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:4.4.9:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:beta1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:beta2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:beta3:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:beta4:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:rc1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:rc2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.0:rc3:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0:rc1:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0:rc2:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.0:rc3:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.1.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.1.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.1.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.1.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.1.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.1.6:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.0:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.1:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.10:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.2:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.3:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.4:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.5:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.6:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.8:*:*:*:*:*:*:*
    • cpe:2.3:a:php:php:5.2.9:*:*:*:*:*:*:*

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

15

News mentions

0

No linked articles in our index yet.