CVE-2026-40902·PHP vulnerability
PhpSpreadsheet is a pure PHP library for reading and writing spreadsheet files. Prior to 1.30.4, 2.1.16, 2.4.5, 3.10.5, and 5.7.0, the XLSX reader's ColumnAndRowAttributes::readRowAttributes() method reads row numbers from XML attributes without validating them against the spreadsheet maximum row limit (AddressRange::MAX_ROW = 1,048,576). An attacker can craft a minimal XLSX file (~1.6KB) containing a <row r="999999999"/> element that inflates cachedHighestRow to 999,999,999, causing any subsequent row iteration to attempt ~1 billion loop cycles and exhaust CPU resources. This vulnerability is fixed in 1.30.4, 2.1.16, 2.4.5, 3.10.5, and 5.7.0.
- Severity
- high
- Software
- PHP
- Fixed in
- 5.7.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.1% — higher than 13% 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-2026-40902 scores 7.5 on CVSS, so a successful attack would be serious — but at <0.1%, 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: 4.0.0
Until: 5.7.0
Fixed in: 5.7.0
How to fix this CVE
Update PHP and PhpSpreadsheet to patched versions immediately to prevent denial-of-service attacks via maliciously crafted XLSX files. Upgrade to PhpSpreadsheet 5.7.0 or later, and ensure your PHP installation is fully patched. This vulnerability allows attackers to exhaust CPU resources by submitting specially crafted spreadsheet files that trigger excessive row iteration.
sudo dnf update php php-pearDefensia detects this vulnerability
WAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Implement rate limiting on file upload endpoints and restrict XLSX file uploads to authenticated users only. Additionally, configure your WAF to reject spreadsheet files larger than 10MB or with XML elements containing row attributes with values exceeding 1048576 (the maximum valid row number in spreadsheets).How to check if you are affected
- Run `php -v` to check the current PHP version installed on your system
- Check if PhpSpreadsheet is installed by running `composer show phpoffice/phpspreadsheet` in your project root, or grep for 'phpoffice/phpspreadsheet' in composer.lock
- Search web server logs for XLSX file uploads or POST requests containing 'row r=' patterns with excessively large numeric values (e.g., 'row r="999999999"') in the last 30 days
- After patching, re-run `composer show phpoffice/phpspreadsheet` or `php -v` to confirm the version is 5.7.0 or later
FAQ
What is CVE-2026-40902?
CVE-2026-40902 is a denial-of-service vulnerability in PhpSpreadsheet that allows attackers to craft minimal XLSX files with invalid row numbers that bypass validation, causing the library to attempt billions of loop iterations and consume all available CPU resources.
Is CVE-2026-40902 being actively exploited?
No, CVE-2026-40902 is not currently listed on the CISA KEV catalog and no public exploits are available, but the vulnerability can be triggered by any user with the ability to upload or process XLSX files.
What versions of PHP are affected by CVE-2026-40902?
Any PHP installation using PhpSpreadsheet versions 4.0.0 through 5.6.x is vulnerable. The vulnerability is fixed in PhpSpreadsheet 5.7.0 and later versions (also patched in 1.30.4, 2.1.16, 2.4.5, and 3.10.5 for earlier major versions).
How do I check if my server is vulnerable to CVE-2026-40902?
Run `composer show phpoffice/phpspreadsheet | grep Version` in your project directory. If the version is below 5.7.0, your server is vulnerable. You can also inspect your composer.lock file for the installed version.
Does Defensia detect CVE-2026-40902?
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-2026-40902 will appear in your dashboard with remediation steps.
Related PHP CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2026-40902. Free for 1 server.
Get started free