agent-task/capi: capiTransport re-attaches Bearer token on cross-host redirect
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia in pkg/cmd/agent-task/capi/client.go, all'interno di capiTransport.RoundTrip, e confronta la gestione di Authorization con api/http_client.go, in particolare api.AddAuthTokenHeader e il relativo controllo redirectHostnameChange. Riproduci il reindirizzamento da host-A a host-B descritto nell'issue e verifica che la richiesta reindirizzata non contenga più il Bearer token, mentre le richieste allo stesso host continuino a contenerlo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
capiTransport.RoundTrip (pkg/cmd/agent-task/capi/client.go:64) sets the Authorization header unconditionally on every request, including redirect follow-ups.
On a cross-host redirect, the Go stdlib's http.Client strips sensitive headers like Authorization, but capiTransport then immediately re-attaches the Bearer token on the next round-trip, effectively undoing the stdlib's protection.
The codebase already has the correct pattern in api.AddAuthTokenHeader (api/http_client.go:108-127), which inspects req.Response.Request to detect a redirect follow-up and skips re-attaching the token when the host changed. The two transports should be consistent with each other.
Steps to reproduce
- Wrap an
http.ClientwithnewCAPITransport(token, "http://host-A", http.DefaultTransport). - Make a GET request to
http://host-A/foo. - Host A responds with HTTP 302 redirecting to
http://host-B/leaked. - Observe that the request to host B includes
Authorization: Bearer <token>.
Expected behavior
Host B should receive an empty Authorization header, matching the behaviour of api.AddAuthTokenHeader and the stdlib's redirect strip.
Proposed fix
Mirror the redirectHostnameChange check from api.AddAuthTokenHeader inside capiTransport.RoundTrip.
- Lingua principale
- Go
- Stelle
- 46.3k
- Fork
- 9.1k
- Merge medio
- 1g 7h
- PR unite (30g)
- 76
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cli/cli
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
-
more-info-needed needs-triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
-
bug gh-pr priority-2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
bug gh-pr priority-2
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug gh-auth priority-3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Issue simili
-
nix: vendorHash is outdated Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
Bob Shell support Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
santhosh-tekuri/jsonschema#276 ·