Skip to content

Fix credential header leak on cross-domain pscale api redirects#1303

Merged
mscoutermarsh merged 2 commits into
mainfrom
cursor/strip-redirect-headers-45be
Jul 22, 2026
Merged

Fix credential header leak on cross-domain pscale api redirects#1303
mscoutermarsh merged 2 commits into
mainfrom
cursor/strip-redirect-headers-45be

Conversation

@mscoutermarsh

@mscoutermarsh mscoutermarsh commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

pscale api follows cross-host redirects in handleRedirect with a fresh HTTP client, but previously copied every original request header except the literal Authorization header. Users can supply arbitrary headers via --header/-H (e.g. Cookie, X-Api-Key, Proxy-Authorization), so those secrets were forwarded to whatever host was named in Location.

Fix

Cross-host redirects now use a fresh GET request with no headers copied from the original request. Stripping only Authorization is insufficient because credentials can live in any user-supplied header name.

Rebased/merged with main after #1301 (exact-host redirect checks). That PR still copied non-Authorization headers; this change keeps the no-header-forwarding behavior on top of the tighter host matching.

Test plan

  • go test ./internal/cmd/api/TestHandleRedirect asserts credential-bearing headers are absent on the redirect request; TestRedirectCheck covers exact-host matching from Fix OAuth token re-sent to sibling subdomains on redirect #1301
  • Manual: pscale api against an endpoint that 302s cross-host with -H 'X-Api-Key: secret' and confirm the secret is not sent to the redirect target
Open in Web Open in Cursor 

handleRedirect previously copied all original request headers except
Authorization when following a cross-domain Location. Users can put
secrets in arbitrary --header/-H values (Cookie, X-Api-Key,
Proxy-Authorization), which were then forwarded to the redirect target.

Follow cross-domain redirects with a fresh request that carries none of
the original headers.

Co-authored-by: Mike Coutermarsh <coutermarsh.mike@gmail.com>
@mscoutermarsh
mscoutermarsh marked this pull request as ready for review July 22, 2026 19:49
@mscoutermarsh
mscoutermarsh requested a review from a team as a code owner July 22, 2026 19:49
Resolve conflict with #1301 exact-host redirect checks. Main still
copied non-Authorization headers on cross-host redirects; keep the
fresh request with no original headers so -H secrets cannot leak.

Co-authored-by: Mike Coutermarsh <coutermarsh.mike@gmail.com>
@mscoutermarsh
mscoutermarsh merged commit 215a84e into main Jul 22, 2026
4 checks passed
@mscoutermarsh
mscoutermarsh deleted the cursor/strip-redirect-headers-45be branch July 22, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants