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.
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 5.0 | php5 | 5.2.6.dfsg.1-1+lenny6 | DSA-2001-1 |
Red Hat
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| RHEL 5 | php +18 | 5.1.6-24.el5_4.5 | RHSA-2010:0040 |
| RHEL 4 | php +13 | 4.3.9-3.29 | RHSA-2010:0040 |
| RHEL 3 | php +6 | 4.3.2-54.ent | RHSA-2010:0040 |
Public exploits
Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.
Exploit-DB 2
- PHP 5.2.11 - 'htmlspecialCharacters()' Malformed Multibyte Character Cross-Site Scripting (1) EDB-33414 · remote · Dec 17, 2009 · verified
- PHP 5.2.11 - 'htmlspecialCharacters()' Malformed Multibyte Character Cross-Site Scripting (2) EDB-33415 · remote · Dec 17, 2009 · verified
Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.
Advisories 2
- RHSA-2010:0040 Red Hat Security Advisory: php security update Red Hat Security Advisories (RHSA) · Jun 26, 2026
- DSA-2001-1 php5 - multiple vulnerabilities Debian Security (DSA / DLA) · Mar 9, 2026
References
- 37389 vdb-entry
- http://www.php.net/releases/5_2_12.php
- http://bugs.php.net/bug.php?id=49785
- 40262 third-party-advisory
- HPSBUX02543 vendor-advisory
- 1023372 vdb-entry
- 37821 third-party-advisory
- 38648 third-party-advisory
- APPLE-SA-2010-03-29-1 vendor-advisory
- http://www.php.net/ChangeLog-5.php
- oval:org.mitre.oval:def:7085 vdb-entry signature
- oval:org.mitre.oval:def:10005 vdb-entry signature
- http://support.apple.com/kb/HT4077
- ADV-2009-3593 vdb-entry
- DSA-2001 vendor-advisory