Harden OPDS proxy SSRF, storage key validation, Stripe check
fix(security): harden OPDS proxy SSRF, storage key validation, Stripe check (#4638)
Harden OPDS proxy SSRF, storage key validation, Stripe check495783-fix-harden-opds-proxy-ssrf-storage-key-cve-2026-57566fixharden opds proxy ssrf storage key
Committed by chrox
commit message
fix(security): harden OPDS proxy SSRF, storage key validation, Stripe check (#4638)
Server-side hardening for three reported web advisories:
- OPDS proxy (/api/opds/proxy): add http(s) scheme allowlist, internal/loopback/
link-local host blocklist, and manual per-hop redirect re-validation so a
public URL can't redirect into an internal address. Move isBlockedHost into
the shared src/utils/network.ts as the canonical blocklist and reimplement
isLanAddress to delegate to it (also tightens the /api/kosync LAN check);
fetch-url.ts re-exports it. (GHSA-c7mm-g2j2-98cx, GHSA-5g3f-mq2c-j65v)
- Storage upload (/api/storage/upload): validate the client-supplied fileName
with a new isSafeObjectKeyName helper before building the object key, so a
name can't escape the caller's own prefix. (GHSA-mfmj-2frf-vhgw)
- Stripe (/api/stripe/check): bind the entitlement to the session owner —
reject a Checkout Session whose metadata.userId differs from the authenticated
caller. (GHSA-pv88-3727-j7v8)
Unit tests added for each path; full suite + lint green. The Tauri-native
advisory (GHSA-55vr-pvq5-6fmg) is handled in a separate change.
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>Editor assessment
This commit patches CVE-2026-57566. A strong triage-style message. The security scope is accurate and the body explains each of the three hardened surfaces: the OPDS proxy gains an http(s) allowlist, loopback and link-local blocking plus per-hop redirect re-validation so a public URL cannot bounce into internal space; the upload path validates fileName with isSafeObjectKeyName so a name cannot escape the caller's prefix; and the Stripe check binds the entitlement to the session owner. Each item names its advisory and its tests. Only the PR number and the triple-item subject keep it from being perfectly clean.