Core: Authorization and Cookie headers leaked to cross-origin servers on HTTP redirect
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 72/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- java
- Domínio
- backend-api-design, security
Direção de pesquisa
Comece em HttpRequest.handleRedirect() e execute(), depois revise os três cenários de regressão descritos na issue. Verifique o comportamento same-origin em alterações de esquema, host e porta, incluindo a normalização da porta padrão; está concluído quando os redirecionamentos cross-origin não contêm os cabeçalhos Authorization e Cookie, enquanto os redirecionamentos same-origin mantêm o comportamento esperado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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.
- Linguagem predominante
- Java
- Estrelas
- 1.4k
- Forks
- 476
- Merge médio
- 10h 47min
- PRs com merge (30d)
- 3
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de googleapis/google-http-java-client
-
Core: Validate header names and values to prevent CRLF injectionTalvez já em andamento @insaf021 assumiu há 106 dias. Abertapriority: p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
-
Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()Talvez já em andamento @insaf021 assumiu há 106 dias. Abertapriority: p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
-
Core: LowLevelHttpResponse not disconnected when HttpResponse construction throws RuntimeExceptionTalvez já em andamento @insaf021 assumiu há 106 dias. Abertapriority: p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
-
type: cleanup
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
-
org.apache.http.conn.ssl.SSLSocketFactory is deprecatedTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Abertapriority: p2 type: cleanup
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Todas as issues de googleapis/google-http-java-client
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 80/100
finos/fluxnova-bpm-platform#387 ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
-
Dificuldade 2/5 Menos de uma hora Facilidade para iniciantes 84/100
cpp-best-practices/project_validator#251 ·
Mantenedores costumam responder em até 1 dia
-
backend enhancement
Dificuldade 2/5 Meio dia Facilidade para iniciantes 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changeTalvez já em andamento @dwizard0 assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 1 dia