CVE-2024-47873

CVE-2024-47873 is a high-severity XML external entity injection (XXE) vulnerability in phpoffice/phpspreadsheet (composer), affecting versions < 1.29.4. It is fixed in 1.29.4, 2.1.3, 2.3.2, 3.4.0.

Summary

The XmlScanner class has a scan method which should prevent XXE attacks.

However, the regexes used in the scan method and the findCharSet method can be bypassed by using UCS-4 and encoding guessing as described in https://www.w3.org/TR/xml/#sec-guessing-no-ext-info.

Details

The scan method converts the input in the UTF-8 encoding if it is not already in the UTF-8 encoding with the toUtf8 method.
Then, the scan method uses a regex which would also work with 16-bit encoding.

However, the regexes from the findCharSet method, which is used for determining the current encoding can be bypassed by using an encoding which has more than 8 bits, since the regex does not expect null bytes, and the XML library will also autodetect the encoding as described in https://www.w3.org/TR/xml/#sec-guessing-no-ext-info.

A payload for the workbook.xml file can for example be created with CyberChef.
If you open an Excel file containing the payload from the link above stored in the workbook.xml file with PhpSpreadsheet, you will receive an HTTP request on 127.0.0.1:12345. You can test that an HTTP request is created by running the nc -nlvp 12345 command before opening the file containing the payload with PhpSpreadsheet.

PoC

  • Create a new folder.
  • Run the composer require phpoffice/phpspreadsheet command in the new folder.
  • Create an index.php file in that folder with the following content:
<?php
require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();

$inputFileType = 'Xlsx';
$inputFileName = './payload.xlsx';

/**  Create a new Reader of the type defined in $inputFileType  **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/**  Advise the Reader that we only want to load cell data  **/
$reader->setReadDataOnly(true);

$worksheetData = $reader->listWorksheetInfo($inputFileName);

foreach ($worksheetData as $worksheet) {

$sheetName = $worksheet['worksheetName'];

echo "<h4>$sheetName</h4>";
/**  Load $inputFileName to a Spreadsheet Object  **/
$reader->setLoadSheetsOnly($sheetName);
$spreadsheet = $reader->load($inputFileName);

$worksheet = $spreadsheet->getActiveSheet();
print_r($worksheet->toArray());

}

Impact

An attacker can bypass the sanitizer and achieve an XXE attack.

An XML parser processes external entity references in untrusted input, causing the server to fetch internal resources or remote URLs. Typical impact: local file disclosure, server-side request forgery, or denial of service.

CVE-2024-47873 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.29.4, 2.1.3, 2.3.2, 3.4.0); upgrading removes the vulnerable code path.

Affected versions

phpoffice/phpspreadsheet (< 1.29.4) phpoffice/phpspreadsheet (>= 2.0.0, < 2.1.3) phpoffice/phpspreadsheet (>= 2.2.0, < 2.3.2) phpoffice/phpspreadsheet (>= 3.3.0, < 3.4.0) phpoffice/phpexcel (<= 1.8.2)

Security releases

phpoffice/phpspreadsheet → 1.29.4 (composer) phpoffice/phpspreadsheet → 2.1.3 (composer) phpoffice/phpspreadsheet → 2.3.2 (composer) phpoffice/phpspreadsheet → 3.4.0 (composer)

Kodem intelligence

Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.

Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.

See it in your environment

Remediation advice

Upgrade the following packages to resolve this vulnerability:

phpoffice/phpspreadsheet to 1.29.4 or later; phpoffice/phpspreadsheet to 2.1.3 or later; phpoffice/phpspreadsheet to 2.3.2 or later; phpoffice/phpspreadsheet to 3.4.0 or later

Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.

Frequently Asked Questions

  1. What is CVE-2024-47873? CVE-2024-47873 is a high-severity XML external entity injection (XXE) vulnerability in phpoffice/phpspreadsheet (composer), affecting versions < 1.29.4. It is fixed in 1.29.4, 2.1.3, 2.3.2, 3.4.0. An XML parser processes external entity references in untrusted input, causing the server to fetch internal resources or remote URLs.
  2. How severe is CVE-2024-47873? CVE-2024-47873 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
  3. Which packages are affected by CVE-2024-47873?
    • phpoffice/phpspreadsheet (composer) (versions < 1.29.4)
    • phpoffice/phpexcel (composer) (versions <= 1.8.2)
  4. Is there a fix for CVE-2024-47873? Yes. CVE-2024-47873 is fixed in 1.29.4, 2.1.3, 2.3.2, 3.4.0. Upgrade to this version or later.
  5. Is CVE-2024-47873 exploitable, and should I be worried? Whether CVE-2024-47873 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
  6. What actually determines whether CVE-2024-47873 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
  7. How do I fix CVE-2024-47873?
    • Upgrade phpoffice/phpspreadsheet to 1.29.4 or later
    • Upgrade phpoffice/phpspreadsheet to 2.1.3 or later
    • Upgrade phpoffice/phpspreadsheet to 2.3.2 or later
    • Upgrade phpoffice/phpspreadsheet to 3.4.0 or later

Other vulnerabilities in phpoffice/phpspreadsheet

CVE-2026-40902CVE-2026-40863CVE-2026-34084CVE-2026-40296CVE-2026-35453

Stop the waste.
Protect your environment with Kodem.