CVE-2019-12331
Description
PHPOffice PhpSpreadsheet before 1.8.0 has an XXE issue. The XmlScanner decodes the sheet1.xml from an .xlsx to utf-8 if something else than UTF-8 is declared in the header. This was a security measurement to prevent CVE-2018-19277 but the fix is not sufficient. By double-encoding the the xml payload to utf-7 it is possible to bypass the check for the string ‚<!ENTITY‘ and thus allowing for an xml external entity processing (XXE) attack.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
PhpSpreadsheet before 1.8.0 fails to properly sanitize XML encoding, allowing XXE attacks by double-encoding payloads in UTF-7 to bypass entity checks.
Vulnerability
Overview
CVE-2019-12331 affects PHPOffice PhpSpreadsheet versions before 1.8.0, where the XmlScanner decodes sheet1.xml from .xlsx files to UTF-8 if a different encoding is declared in the header. This behavior was intended to mitigate CVE-2018-19277, but the fix proved insufficient [2]. By double-encoding the XML payload to UTF-7, an attacker can bypass the check for the string <!ENTITY and perform an XML External Entity (XXE) processing attack [1][2].
Exploitation
Details
The root cause lies in the XmlScanner's handling of encoding declarations. The scanner attempted to convert non-UTF-8 XML to UTF-8, but it did not account for attacks using multiple encoding layers, such as UTF-7. An attacker can craft a malicious .xlsx file with a sheet1.xml that declares UTF-7 encoding and includes a double-encoded entity reference. This bypasses the pattern check for <!ENTITY because the string is not present in the decoded UTF-8 form [2]. The vulnerability can be triggered without authentication if the application processes user-uploaded spreadsheet files.
Impact
Successful exploitation allows an XXE attack, potentially leading to disclosure of local files, server-side request forgery (SSRF), denial of service, or other impacts depending on the application's context. Since PhpSpreadsheet is a PHP library used for reading and writing spreadsheet files, any web application that accepts .xlsx uploads and processes them with an affected version is at risk [4].
Mitigation
The vulnerability is fixed in PhpSpreadsheet version 1.8.0. The patch (commit 0e6238c) improves the XmlScanner to properly disable entity loader and handle encoding conversions more securely [1][3]. Users should upgrade to version 1.8.0 or later. There is no mention of a workaround for older versions, and the vendor recommends upgrading as the primary mitigation [3][4].
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
phpoffice/phpspreadsheetPackagist | < 1.8.0 | 1.8.0 |
phpoffice/phpexcelPackagist | <= 1.8.2 | — |
Affected products
3- PHPOffice/PhpSpreadsheetdescription
- ghsa-coords2 versions
<= 1.8.2+ 1 more
- (no CPE)range: <= 1.8.2
- (no CPE)range: < 1.8.0
Patches
0No patches discovered yet.
Vulnerability mechanics
AI mechanics synthesis has not run for this CVE yet.
References
9- github.com/advisories/GHSA-vvwv-h69m-wg6fghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2019-12331ghsaADVISORY
- github.com/FriendsOfPHP/security-advisories/blob/master/phpoffice/phpspreadsheet/CVE-2019-12331.yamlghsaWEB
- github.com/PHPOffice/PhpSpreadsheet/blob/master/CHANGELOG.mdghsax_refsource_CONFIRMWEB
- github.com/PHPOffice/PhpSpreadsheet/commit/0e6238c69e863b58aeece61e48ea032696c6dccdghsaWEB
- github.com/PHPOffice/PhpSpreadsheet/pull/1041ghsaWEB
- github.com/PHPOffice/PhpSpreadsheet/releases/tag/1.8.0ghsaWEB
- herolab.usd.de/security-advisories/usd-2019-0046ghsaWEB
- herolab.usd.de/security-advisories/usd-2019-0046/mitrex_refsource_MISC
News mentions
0No linked articles in our index yet.