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

オープン
#2,181 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@insaf021 がすでに取り組んでいます。

2026年7月31日 から。

  • #2182 @insaf021 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
java

調査の方向性

HttpRequest.handleRedirect() と execute() から始め、その後、issue に記載されている 3 つのリグレッションシナリオを確認します。スキーム、ホスト、ポートの変更全体で、デフォルトポートの正規化を含む same-origin の動作を検証します。cross-origin のリダイレクトで Authorization ヘッダーと Cookie ヘッダーが存在せず、same-origin のリダイレクトで期待される動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

priority: p3

Environment details

  1. Core - HttpRequest in google-http-client
  2. OS type and version: Any
  3. Java version: Any (Java 8+)
  4. google-http-client version: reproducible on current main

Problem Statement
When HttpRequest follows a redirect to a different origin (different scheme, host, or port),
the Cookie header is not stripped. Additionally, Authorization headers set via interceptors
(e.g. BasicAuthentication) are re-applied by the interceptor on subsequent redirect
iterations regardless of destination origin. This can cause credentials to be silently
forwarded to attacker-controlled servers.

Steps to reproduce

  1. Build an HttpRequest with an Authorization interceptor (e.g. BasicAuthentication) and a
    Cookie header.
  2. Configure the transport to return a 302 redirect to a cross-origin URL (different host).
  3. Execute the request.
  4. Observe that the second request (to the cross-origin target) still includes Authorization
    and Cookie headers.

Proposed Fix
In handleRedirect(), compute whether the new URL is same-origin as the old URL (comparing
scheme, host, and effective port). Strip Cookie header if cross-origin. In execute(), before
each retry, compare current URL origin to original origin and strip Authorization and Cookie
if the URL has changed to a different origin (e.g. after a previous redirect).

Add getEffectivePort() and isSameOrigin() helpers to normalize default ports (80 for http,
443 for https).

Three regression tests are included in the accompanying PR covering same-origin,
cross-origin host change, scheme change, and port change scenarios.

主要言語
Java
スター
1.4k
フォーク
476
平均マージ
10時間 47分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-http-java-client のほかの issue

googleapis/google-http-java-client の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。