GHSA-2phh-27fw-q4gc: SSRF

Published Oct 27, 2026
·
Updated

Summary PhpSpreadsheet's Worksheet\Drawing::setPath() validates an external-image URL against an operator-supplied isWhitelisted callback once, on the initial URL only, then fetches it with filegetcontents() using a stream context that does not set followlocation => 0. A whitelisted host that returns an HTTP 302 Location: redirect to an internal target is therefore followed by PHP's HTTP wrapper (default followlocation=1, maxredirects=20) with no re-validation of the redirect hop — defeating the whitelist and yielding a blind SSRF from the server.

This is an unfixed variant of CVE-2026-59931 (GHSA-6hq5-7373-42rg, the WEBSERVICE redirect-whitelist-bypass): the followlocation => 0 fix (commit 7ef7b25e) was applied ONLY to Calculation/Web/Service.php; Worksheet/Drawing.php was never touched.

Root Cause src/PhpSpreadsheet/Worksheet/Drawing.php: - Scheme allowlist at :125 (/^(http|https|file|ftp|s3):/) permits http/https (the redirect-following schemes) and runs on the initial URL only. - Opt-in gate if (!$allowExternal) at :128 (requires setAllowExternalImages(true); default false, BaseReader.php:55). - Whitelist check if ($isWhitelisted !== null && !$isWhitelisted($path)) at :131 — validates the INITIAL URL only; never re-applied after a redirect. - Stream context built at :140-152 sets useragent + header (+ ssl.cryptomethod for https) but omits followlocation. git grep followlocation on tag 5.9.0 yields a single hit — Service.php:45 (the CVE-2026-59931 fix) — confirming it was never added to Drawing.php. - Sink filegetcontents($path, false, $ctx) at :154.

Impact Blind SSRF from the server: reach and trigger internal GET-driven endpoints, coarse internal reachability/port probing, and reach cloud-metadata endpoints. The fetched body is written to a temp file, checked with isImage() (mime image/, or application/octet-stream with bin/emf extension), only image dimensions are stored, and the temp file is unlinked — so the response body is not exfiltrated (non-image responses fail isImage()). This is a blind GET primitive, not full response read.

Proof of Concept 1. Attacker server https://trusted-whitelisted.example/redir.png returns 302 Location: http://169.254.169.254/latest/meta-data/. 2. evil.xlsx with xl/drawings/rels/drawing1.xml.rels: <Relationship ... Type=".../image" Target="https://trusted-whitelisted.example/redir.png" TargetMode="External"/>. 3. Victim: $r = new Xlsx(); $r->setAllowExternalImages(true)->setIsWhitelisted(fn($p)=>strcontains($p,'trusted-whitelisted.example')); $r->load('evil.xlsx'); -> the server-side GET is forced to the internal target despite the whitelist. HTML-reader variant: <img src="https://trusted-whitelisted.example/redir.png"> loaded via Reader\Html (Html.php:1237) with the same reader settings.

Attack Chain 1. Entry: crafted evil.xlsx, xl/drawings/rels/.rels TargetMode="External", Target="https://trusted.example/redir.png" (whitelisted host). Guard: none (legal external-image relationship). Bypass proof: Target stored verbatim -> $url at Reader/Xlsx.php:1544. 2. Config: victim loads with setAllowExternalImages(true)->setIsWhitelisted($cb) where $cb allows trusted.example. Guard: Drawing.php:128 opt-in (satisfied) + :131 whitelist. Bypass proof: initial URL is whitelisted -> returns true; check runs once on $path. 3. Fetch/redirect: filegetcontents (:154) GETs the URL; whitelisted host returns 302 Location: http://169.254.169.254/.... Guard: stream context (:140-152). Bypass proof: no followlocation key -> PHP follows the redirect (default followlocation=1, maxredirects=20) with no re-validation. 4. Impact: server issues a blind GET to the internal target (body temp-filed, isImage()-checked, dimensions stored, temp file unlinked — body not exfiltrated).

Bypass Evidence - git grep followlocation 5.9.0 -- src/ -> single hit at Service.php:45; Drawing.php has none. - CVE-2026-59931's own regression harness (ServerTest.php + redirect.php: a whitelisted host 302-redirects to direct.php; only after followlocation => 0 does the fetch stop following it) demonstrates the exact behavior. That fix is present in Service.php and absent in Drawing.php. - git grep isWhitelisted 5.9.0 -- src/ confirms the callback is applied only at Drawing.php:131 (initial $path), never after the redirect.

Affected Versions >= 5.5.0, <= 5.9.0. The isWhitelisted control being bypassed was introduced in 5.5.0 (commit 50a7552f); present and unfixed on the latest release (5.9.0) and on HEAD (05e99ebf). No post-release fix to Drawing.php.

Suggested Fix Add 'followlocation' => 0 (and/or 'maxredirects' => 0) to $ctxArray['http'] in Drawing::setPath() (:140-148), mirroring the CVE-2026-59931 fix at Service.php:45; alternatively follow redirects manually and re-run $isWhitelisted on each hop.

--- Reported by zx (Jace) — GitHub: @manus-use

Affected Software

5 affected componentsFixes available
composer/phpoffice/phpspreadsheet<=1.30.6
1.30.7
composer/phpoffice/phpspreadsheet>=2.0.0<=2.1.18
2.1.19
composer/phpoffice/phpspreadsheet>=2.2.0<=2.4.7
2.4.8
composer/phpoffice/phpspreadsheet>=3.3.0<=3.10.7
3.10.8
composer/phpoffice/phpspreadsheet>=4.0.0<=5.9.0
5.10.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.7
  2. Upgrade

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

    Fixed in 2.1.19
  3. Upgrade

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

    Fixed in 2.4.8
  4. Upgrade

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

    Fixed in 3.10.8
  5. Upgrade

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

    Fixed in 5.10.0
  6. Configuration

    Add 'follow_location' => 0 to the HTTP stream context in Drawing::setPath() to prevent redirects from bypassing the initial isWhitelisted check.

    PhpSpreadsheet Worksheet\Drawing::setPath() follow_location = 0

Event History

Oct 27, 2026
Advisory Published
via GitHub·03:38 PM
Data Sourced
via GitHub·03:38 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Is the default configuration affected?

External image fetching is disabled by default because setAllowExternalImages(true) must be explicitly enabled. The redirect bypass applies only when external images are allowed.

2

What conditions are required for exploitation?

An attacker needs an external image URL whose initial host passes the operator-supplied isWhitelisted callback and that responds with a redirect to an internal target. The HTTP client follows redirects without applying the whitelist check to the redirected destination.

3

What can be done if updating is not immediately possible?

Disable external image fetching by ensuring setAllowExternalImages(true) is not enabled. This prevents Worksheet\Drawing::setPath() from retrieving external image URLs.

4

How can I determine whether an application is exposed?

Review code and configuration for calls to setAllowExternalImages(true), use of Worksheet\Drawing::setPath() with HTTP or HTTPS URLs, and an isWhitelisted callback used to approve those URLs. A whitelist that permits hosts capable of redirecting makes the redirect behavior relevant.

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