Skip to content

security: strip Authorization and Cookie headers on cross-origin redirects - #2182

Open
insaf021 wants to merge 1 commit into
googleapis:mainfrom
insaf021:security/redirect-credential-leak
Open

security: strip Authorization and Cookie headers on cross-origin redirects#2182
insaf021 wants to merge 1 commit into
googleapis:mainfrom
insaf021:security/redirect-credential-leak

Conversation

@insaf021

Copy link
Copy Markdown

Summary
HttpRequest now strips Authorization and Cookie headers before following cross-origin
redirects (different scheme, host, or port), preventing credential leakage.

Changes

  • HttpRequest.java: tracks original origin, clears Authorization/Cookie on origin change
    between retries; handleRedirect() strips Cookie on cross-origin redirects using new
    getEffectivePort()/isSameOrigin() helpers.

  • HttpRequestTest.java: adds tests for host/scheme/port changes and default-port
    equivalence.

  • Opened an issue before writing code

  • Tests and linter pass

  • Code coverage does not decrease

  • Docs updated

Fixes #2181

@insaf021
insaf021 requested a review from a team as a code owner July 31, 2026 04:28
@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Jul 31, 2026
@insaf021 insaf021 changed the title security: strip Authorization and Cookie headers on cross-origin redi… security: strip Authorization and Cookie headers on cross-origin redirects Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core: Authorization and Cookie headers leaked to cross-origin servers on HTTP redirect

1 participant