caddyauth: only replace known placeholders in basic auth credentials - #8017
Open
hktitof wants to merge 1 commit into
Open
caddyauth: only replace known placeholders in basic auth credentials#8017hktitof wants to merge 1 commit into
hktitof wants to merge 1 commit into
Conversation
The basic auth provider expanded account usernames and passwords with
repl.ReplaceAll, which blanks any {...} the replacer does not recognize
Credentials are config data, so a username like alice-{bogus} was stored
as alice- and a password like ab{cd}ef was quietly rewritten into
different valid base64, turning a config mistake into a working
password the admin never set
Use ReplaceKnown, matching the respond headers fix in caddyserver#8014 and the
header handler fix in caddyserver#4880, so unknown braces survive and real
placeholders like {env.*} still expand
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.
Fixes #8016
Summary
the basic auth provider expanded account usernames and passwords with
repl.ReplaceAll, which blanks any{...}the replacer does not recognize, so a username likealice-{bogus}was provisioned asalice-and a password likeab{cd}efwas quietly rewritten into different valid base64this switches both to
repl.ReplaceKnown, matching the respond headers fix in #8014 and the header handler fix in #4880 (same class as #4418), so unrecognized braces in credentials are left intact and real placeholders like{env.*}still expandSteps to reproduce
go test ./modules/caddyhttp/caddyauth/ -run TestBasicAuth -count=1{...}in usernames survive as literal data, a braced password is rejected instead of silently rewritten,{env.*}placeholders still expandregression tests in
basicauth_test.gopin all three directions: unknown braces survive, a known placeholder still expands, and a braced password fails loudly instead of becoming a different valid passwordAssistance Disclosure
AI used: yes, for drafting test coverage and description formatting