VYPR
High severityNVD Advisory· Published Nov 7, 2019· Updated Aug 4, 2024

CVE-2019-12331

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.

PackageAffected versionsPatched versions
phpoffice/phpspreadsheetPackagist
< 1.8.01.8.0
phpoffice/phpexcelPackagist
<= 1.8.2

Affected products

3

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

9

News mentions

0

No linked articles in our index yet.