Skip to content

Block cross-host redirects and restrict bearer token to expected host#2354

Merged
Hayden-IO merged 1 commit into
mainfrom
bugfix
May 26, 2026
Merged

Block cross-host redirects and restrict bearer token to expected host#2354
Hayden-IO merged 1 commit into
mainfrom
bugfix

Conversation

@Hayden-IO

Copy link
Copy Markdown
Contributor

Secures the outbound OIDC discovery request flow against SSRF, JWKS substitution, and credential leakage.

Blocks cross-host redirects: Configures a custom CheckRedirect callback on all OIDC discovery clients to reject redirects that attempt to leave the original issuer's host boundary. SSRF was previously mitigated by adding anchors to the meta issuer regex, but this was not a complete mitigation since a malicious meta issuer could specify an HTTP redirect, which the Go HTTP client would follow by default.

Restricts bearer token injection: Updates bearerTokenTransport to only attach the Kubernetes service-account bearer token when the outgoing request destination host exactly matches the expected issuer's host. This prevents token leakage during both redirect scenarios and cross-host JWKS URIs.

Summary

Release Note

Documentation

Secures the outbound OIDC discovery request flow against SSRF, JWKS substitution, and credential leakage.

Blocks cross-host redirects: Configures a custom CheckRedirect callback on all OIDC discovery clients to
reject redirects that attempt to leave the original issuer's host boundary. SSRF was previously mitigated by
adding anchors to the meta issuer regex, but this was not a complete
mitigation since a malicious meta issuer could specify an HTTP redirect,
which the Go HTTP client would follow by default.

Restricts bearer token injection: Updates bearerTokenTransport to only attach the Kubernetes service-account
bearer token when the outgoing request destination host exactly matches the expected issuer's host.
This prevents token leakage during both redirect scenarios and cross-host JWKS URIs.

Signed-off-by: Hayden <8418760+Hayden-IO@users.noreply.github.com>
@Hayden-IO Hayden-IO requested a review from a team as a code owner May 26, 2026 22:15
@Hayden-IO Hayden-IO enabled auto-merge (squash) May 26, 2026 22:16
@Hayden-IO Hayden-IO merged commit 378c654 into main May 26, 2026
17 checks passed
@Hayden-IO Hayden-IO deleted the bugfix branch May 26, 2026 22:21
Hayden-IO pushed a commit that referenced this pull request May 29, 2026
…ath (#2356)

Gate the in-cluster CA + bearer-token attachment in httpClientForIssuer on
the issuer being directly listed in OIDCIssuers, in addition to the existing
match against k8sIssuerURL. Clusters whose --service-account-issuer is not
literally https://kubernetes.default.svc (e.g. K3s, which uses
https://kubernetes.default.svc.cluster.local) can again use the in-cluster
auth path when their issuer URL is explicitly listed in OIDCIssuers.

The SSRF/token-leak protection from #2354 is preserved: MetaIssuer wildcard
matches against attacker-controlled hosts still do not receive the bearer
token, because the new gate trusts only directly-listed OIDCIssuers entries
(and the default k8sIssuerURL itself).

Fixes #2355.

Signed-off-by: Kevin Monroe <kevin.monroe@chainguard.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants