Repository navigation
fix(auth): omit token-provider response bodies from errors - #5263
singh4jitendra wants to merge 1 commit into
Conversation
Keep the standard OAuth retrieval error and HTTP status for retry decisions without echoing potentially sensitive provider payloads. Cover dummy JSON and plaintext error responses and document the diagnostic change.
There was a problem hiding this comment.
Code Review
This pull request prevents credential-provider response bodies, which may contain sensitive tokens or secrets, from being exposed in error logs when a token request fails. Specifically, the Body field is omitted from oauth2.RetrieveError in internal/auth/token_source.go. Corresponding documentation has been added to docs/client_and_retries.md, and a new unit test has been introduced to verify that response bodies are not leaked. I have no additional feedback to provide as the changes are well-implemented and there are no review comments.
|
Hi @geertj, could you help approve CI and review the token-provider error-body change when you have a moment? Happy to address any feedback. Thanks! |
|
Hi @geertj, could you help get CI running and review the token-provider error-body fix when you have time? Please let me know if anything needs adjusting. Thanks! |
|
Hi @geertj, could you review the token-provider error-body fix when you have a moment? Thanks! |
Description
A token provider's error body can contain credentials. Returning that body in
oauth2.RetrieveErroralso copies it into the error message, which callers may log.This leaves the HTTP status and standard error type available for diagnostics and retries, but omits the body. Successful token responses are unchanged. Tests cover JSON and plain-text responses using dummy values.
This is separate from the provider timeout/lifetime work in #5230.
Link to the issue in case of a bug fix.
Fixes #5257
Testing details
Go 1.27.4, Linux under WSL.
CGO_ENABLED=0and a longer local lint budget:printf 'lint: vet\n\tgolangci-lint run -E=unused --timeout 10m0s --new-from-rev=master\n' | make -f Makefile -f - build- passed with0lint issues. No build checks were skipped.go test -mod=readonly -p 1 -count=1 -timeout=90s -run '^TestProxyTokenSourceErrorDoesNotExposeResponseBody$' ./internal/auth- failed as expected before the fix, showing the dummy response values in the error.go test -mod=readonly -p 1 -count=1 -race -timeout=3m ./internal/auth ./internal/storage/storageutil- passed on native Linux storage, including expiry, Unix sockets and status-based retry behavior.Any backward incompatible change? If so, please explain.
Provider response bodies are intentionally no longer included in errors. The HTTP status, retry classification, success behavior and response-size cap remain unchanged. Provider-specific details should be checked in the provider's own logs.