Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

agent-task/capi: capiTransport re-attaches Bearer token on cross-host redirect

Aperta Adatta ai principianti
#13,464 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
go
Ambito
api, security

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

enhancement gh-agent-task

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

  1. Wrap an http.Client with newCAPITransport(token, "http://host-A", http.DefaultTransport).
  2. Make a GET request to http://host-A/foo.
  3. Host A responds with HTTP 302 redirecting to http://host-B/leaked.
  4. 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di cli/cli

Tutte le issue di cli/cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.