CVE-2019-12331: Phpoffice/phpspreadsheet Security Vulnerability Vulnerability
HIGHCVE-2019-12331 is a HIGH (CVSS 8.8) security vulnerability vulnerability (CWE-611: Improper Restriction of XML External Entity Reference) affecting Phpoffice/phpspreadsheet libraries in the Packagist ecosystem. The issue involves xxe in phpspreadsheet due to incomplete fix for previous encoding issue. Remediation is available by upgrading affected packages to version 1.8.0.
CVE-2019-12331 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2019-12331
To remediate this vulnerability, upgrade all affected Phpoffice/phpspreadsheet dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade phpoffice/phpspreadsheet to 1.8.0
Upgrade phpoffice/phpexcel to Latest secure release
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for phpoffice/phpspreadsheet
How to Check if You Are Affected
To determine whether your application is affected by CVE-2019-12331, inspect your project dependencies for Phpoffice/phpspreadsheet:
inspect dependencies for phpoffice/phpspreadsheet
Analyze the terminal output to locate any version of Phpoffice/phpspreadsheet in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.8.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-611: Improper Restriction of XML External Entity Reference, where the product processes an xml document that can contain xml entities with uris that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. In Phpoffice/phpspreadsheet, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2019-12331 Affected Phpoffice/phpspreadsheet Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
phpoffice/phpspreadsheet
|
Packagist |
< 1.8.0
|
1.8.0
|
|
phpoffice/phpexcel
|
Packagist |
≤ 1.8.2
|
|
References
Frequently Asked Questions
What is CVE-2019-12331?
Which Phpoffice/phpspreadsheet versions are affected?
What version fixes CVE-2019-12331?
Is phpoffice/phpspreadsheet affected?
Is phpoffice/phpexcel affected?
What is the CVSS score of CVE-2019-12331?
What CWE is associated with CVE-2019-12331?
How can I check Packagist dependencies for CVE-2019-12331?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-vvwv-h69m-wg6f",
"modified" : "2025-03-06T18:02:26Z",
"published" : "2019-11-20T01:39:57Z",
"aliases" : [ "CVE-2019-12331" ],
"summary" : "XXE in PHPSpreadsheet due to incomplete fix for previous encoding issue",
"details" : "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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpspreadsheet"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.8.0"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "phpoffice/phpexcel"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"last_affected" : "1.8.2"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2019-12331"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/pull/1041"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/commit/0e6238c69e863b58aeece61e48ea032696c6dccd"
}, {
"type" : "WEB",
"url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/phpoffice/phpspreadsheet/CVE-2019-12331.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/blob/master/CHANGELOG.md#180---2019-07-01"
}, {
"type" : "WEB",
"url" : "https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/1.8.0"
}, {
"type" : "WEB",
"url" : "https://herolab.usd.de/security-advisories/usd-2019-0046"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-611" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2019-11-19T03:41:04Z",
"nvd_published_at" : "2019-11-07T15:15:10Z"
}
}