CVE-2024-47873

7.5 HIGH
XXE

📋 TL;DR

This vulnerability allows attackers to bypass XML external entity (XXE) protection in PhpSpreadsheet by exploiting UCS-4 encoding and encoding guessing weaknesses. It affects PHP applications that process untrusted spreadsheet files using vulnerable PhpSpreadsheet versions, potentially leading to sensitive data exposure or server-side request forgery.

💻 Affected Systems

Products:
  • PHPOffice PhpSpreadsheet
Versions: All versions before 1.9.4, 2.1.3, 2.3.2, and 3.4.0
Operating Systems: All operating systems running PHP
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications that process XML-based spreadsheet files (XLSX, ODS) from untrusted sources using the XmlScanner class.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete server compromise through file disclosure, internal network reconnaissance, or denial of service via entity expansion attacks.

🟠

Likely Case

Sensitive file disclosure from the server filesystem, including configuration files, source code, or credentials.

🟢

If Mitigated

Limited impact if proper input validation and network segmentation are in place, though some information disclosure may still occur.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: MEDIUM

Exploitation requires the attacker to craft a malicious spreadsheet file that gets processed by the vulnerable library.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 1.9.4, 2.1.3, 2.3.2, or 3.4.0 depending on your major version

Vendor Advisory: https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-jw4x-v69f-hh5w

Restart Required: No

Instructions:

1. Identify your PhpSpreadsheet version. 2. Update via Composer: composer require phpoffice/phpspreadsheet:^1.9.4 (or appropriate version). 3. Test spreadsheet processing functionality.

🔧 Temporary Workarounds

Disable XML external entity processing

all

Configure PHP to disable external entity loading globally

php -i | grep libxml
Set libxml_disable_entity_loader(true) in PHP code

Input validation

all

Validate and sanitize all spreadsheet file inputs before processing

🧯 If You Can't Patch

  • Implement strict file type validation and reject any non-whitelisted spreadsheet formats
  • Run PhpSpreadsheet in a sandboxed environment with restricted filesystem and network access

🔍 How to Verify

Check if Vulnerable:

Check composer.json or run: php -r "require 'vendor/autoload.php'; echo \PhpOffice\PhpSpreadsheet\Settings::VERSION;"

Check Version:

composer show phpoffice/phpspreadsheet | grep versions

Verify Fix Applied:

Verify version is 1.9.4+, 2.1.3+, 2.3.2+, or 3.4.0+ and test with known malicious XXE payloads

📡 Detection & Monitoring

Log Indicators:

  • Unusual file read operations from PHP process
  • Outbound HTTP requests to internal IPs from spreadsheet processing

Network Indicators:

  • HTTP requests to internal services originating from web server during file upload processing

SIEM Query:

source="web_server" AND (uri_path="*upload*" OR uri_path="*import*") AND (http_user_agent="*PHP*" OR process="php")

🔗 References

📤 Share & Export