Repository navigation
fix(api)!: stop copying the basic password into Basic-Secret - #69
Merged
Merged
Conversation
BasicToken copied the plain password into the Basic-Secret request header, where anything that forwards, dumps or logs request headers could leak it. It no longer sets the header, and it removes one the client sent, so a handler never reads a client-chosen value there. Basic-Client is still set. This applies to the default instance and to api.New instances. BREAKING CHANGE: BasicToken no longer sets the Basic-Secret request header. Handlers that read Basic-Secret must take the password from their own credential source, for example r.BasicAuth() or their secret store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reason
After a successful check,
api.BasicTokencopied the plain password into theBasic-Secretrequest header. Anything downstream that forwards, dumps or logs request headers could leak it (SEC-02, part 3). The owner decided on 2026-11-21 to remove it in v1.0.0, on the default instance and onapi.Newinstances, as a breaking change.Scope
BasicTokenno longer setsBasic-Secret.Basic-Secretheader the client sent. v0 overwrote that header, so a handler may still trust its value. Without the delete, a client could inject a value there.Basic-Client(the user name) is still set.ValidateBasicTokenkeeps its(client, secret, valid)signature.master, not stacked. It merges cleanly with fix(api): send the request info error from RequestBasic getters #68, and tests pass on the merged tree. Stack: 1 of 2. feat(api): stop copying the token in RequestHeaderSession on instances #70 (RequestHeaderSessionon instances) is stacked on this PR, because both edit adjacent README lines. Merge this PR first, then retarget feat(api): stop copying the token in RequestHeaderSession on instances #70 tomaster.Changes
middlewares.go: dropr.Header.Set("Basic-Secret", secret), addr.Header.Del("Basic-Secret"), and update the doc comment.security_test.go: three tests, each run on the default instance and on an instance:Basic-Secretis removed;Basic-Clientis still set.README.md: security note.docs/migration-v1.md:Release notes
Breaking change:
api.BasicTokenno longer copies the plain password into theBasic-Secretrequest header. It also removes aBasic-Secretheader the client sent. This applies to the default instance and toapi.Newinstances.Basic-Clientis still set. Handlers that readBasic-Secretmust take the password from their own credential source, for exampler.BasicAuth()or their secret store.Verification
TestBasicTokenDoesNotCopyThePasswordIntoBasicSecretandTestBasicTokenRemovesAClientSentBasicSecretfail on the oldmiddlewares.goand pass after the change.gofmt -l .prints nothing;go vet ./...ok;go test -race ./...ok (all packages);govulncheck ./...: no vulnerabilities found.🤖 Generated with Claude Code