CVE-2024-47873·PHP vulnerability
PhpSpreadsheet is a PHP library for reading and writing spreadsheet files. The XmlScanner class has a scan method which should prevent XXE attacks. However, prior to versions 1.9.4, 2.1.3, 2.3.2, and 3.4.0, the regexes used in the `scan` method and the findCharSet method can be bypassed by using UCS-4 and encoding guessing. An attacker can bypass the sanitizer and achieve an XML external entity attack. Versions 1.9.4, 2.1.3, 2.3.2, and 3.4.0 fix the issue.
- Severity
- high
- Software
- PHP
- Fixed in
- 3.4.0
- Published
How likely is exploitation
FIRST's Exploit Prediction Scoring System puts the probability of this CVE being exploited in the next 30 days at 0.76% — higher than 51% of all published CVEs. EPSS is an independent forecast of exploitation, not a severity rating: it says nothing about how much damage a successful attack does, which is what a CVSS score measures.
Read the two together. CVE-2024-47873 scores 7.5 on CVSS, so a successful attack would be serious — but at 0.76%, almost nobody is currently attempting it. That is a different situation from a flaw under mass exploitation, and it is usually the difference between patching on your next maintenance window and patching tonight.
Affected versions
From: 3.3.0
Until: 3.4.0
Fixed in: 3.4.0
How to fix this CVE
Upgrade PHP and PhpSpreadsheet to version 3.4.0 or later to patch the XXE vulnerability in the XmlScanner class. This vulnerability allows attackers to bypass XML sanitization through UCS-4 encoding and character set guessing, potentially leading to information disclosure. Update your PHP environment and rebuild any Docker containers or deployment artifacts using the patched versions.
sudo dnf update php php-cli php-fpmDefensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
POST|GET request containing spreadsheet file upload (.xlsx, .xls, .xml) with payload including XML declarations like `<!DOCTYPE` followed by `SYSTEM` or `PUBLIC` keywords referencing `file://`, `http://`, or gopher protocols; regex: `(<!DOCTYPE|<!ENTITY).*?(SYSTEM|PUBLIC).*?(file|http|gopher)://`WAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Block or sanitize multipart form uploads containing XML Content-Type headers with DOCTYPE or ENTITY declarations; implement strict file type validation on spreadsheet uploads and reject files containing XXE patterns before they reach the application layer.How to check if you are affected
- Run `php -v` to check the current PHP version installed on the system.
- Check if PhpSpreadsheet is installed via Composer by running `composer show phpoffice/phpspreadsheet` or examine vendor/phpoffice/phpspreadsheet/composer.json for version information.
- Search application logs and web server access logs for malicious XML payloads containing DOCTYPE declarations or ENTITY definitions targeting local file systems (e.g., patterns like `<!DOCTYPE` or `SYSTEM "file://`).
- Verify the patch was applied by confirming PHP version is current and re-running `composer show phpoffice/phpspreadsheet` to confirm version 3.4.0 or later is installed.
FAQ
What is CVE-2024-47873?
CVE-2024-47873 is an XXE (XML External Entity) injection vulnerability in PhpSpreadsheet's XmlScanner class that can be bypassed using UCS-4 encoding and character set guessing techniques, allowing attackers to read sensitive files or perform information disclosure attacks through maliciously crafted spreadsheet files.
Is CVE-2024-47873 being actively exploited?
No, according to CISA's KEV catalog, CVE-2024-47873 is not currently listed as actively exploited in the wild, and no public exploits are publicly available.
What versions of PHP are affected by CVE-2024-47873?
PhpSpreadsheet versions 3.3.0 through 3.3.x are affected; patched versions include 1.9.4, 2.1.3, 2.3.2, and 3.4.0 depending on your version branch.
How do I check if my server is vulnerable to CVE-2024-47873?
Run `composer show phpoffice/phpspreadsheet` to determine the installed version; if it is below 3.4.0, 2.3.2, 2.1.3, or 1.9.4 depending on your branch, your system is vulnerable.
Does Defensia detect CVE-2024-47873?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If PHP and PhpSpreadsheet are installed on a monitored server, CVE-2024-47873 will appear in your dashboard with remediation steps.
Related PHP CVEs
References
- https://github.com/PHPOffice/PhpSpreadsheet/blob/39fc51309181e82593b06e2fa8e45ef8333a0335/src/PhpSpreadsheet/Reader/Security/XmlScanner.php
- https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-jw4x-v69f-hh5w
- https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing
- https://www.w3.org/TR/xml/#sec-guessing-no-ext-info
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-47873. Free for 1 server.
Get started free