Core: Authorization and Cookie headers leaked to cross-origin servers on HTTP redirect
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- java
- Lĩnh vực
- backend-api-design, security
Hướng nghiên cứu
Bắt đầu trong HttpRequest.handleRedirect() và execute(), sau đó xem xét ba kịch bản hồi quy được mô tả trong issue. Xác minh hành vi same-origin khi thay đổi scheme, host và port, bao gồm cả việc chuẩn hóa port mặc định; hoàn tất khi các chuyển hướng cross-origin không có các header Authorization và Cookie, trong khi các chuyển hướng same-origin vẫn giữ hành vi mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Environment details
- Core - HttpRequest in google-http-client
- OS type and version: Any
- Java version: Any (Java 8+)
- 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
- Build an HttpRequest with an Authorization interceptor (e.g. BasicAuthentication) and a
Cookie header. - Configure the transport to return a 302 redirect to a cross-origin URL (different host).
- Execute the request.
- 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.
- Ngôn ngữ chính
- Java
- Star
- 1.4k
- Fork
- 476
- Merge trung bình
- 10 giờ 47 phút
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-http-java-client
-
Core: Validate header names and values to prevent CRLF injectionCó thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()Có thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Core: LowLevelHttpResponse not disconnected when HttpResponse construction throws RuntimeExceptionCó thể đã có người làm @insaf021 đã nhận 106 ngày trước. Đang mởpriority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
type: cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
org.apache.http.conn.ssl.SSLSocketFactory is deprecatedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởpriority: p2 type: cleanup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Tất cả issue của googleapis/google-http-java-client
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 84/100
cpp-best-practices/project_validator#251 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend enhancement
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changeCó thể đã có người làm @dwizard0 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày