You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
basic auth blanks literal braces in usernames and passwords (unknown placeholders) #8016
the basic auth provider expands account usernames and passwords with repl.ReplaceAll, which blanks any {...} the replacer does not recognize
a config like
basic_auth {
alice-{bogus} <bcrypt hash>
}
provisions the account as alice- (unknown braces swallowed), and a password value with braces like ab{cd}ef is quietly rewritten to abef, which still parses as valid base64 but is not a usable bcrypt hash, so the config mistake passes provisioning silently and logins just fail instead of the config erroring
respond headers were switched to repl.ReplaceKnown in #8014 and the header handler in #4880 (same class as #4418), so basic auth credentials look like the remaining config-data site still on ReplaceAll
go test ./modules/caddyhttp/caddyauth/ -run TestBasicAuth -count=1
raw output on untouched master:
--- FAIL: TestBasicAuthProvisionKeepsUnknownPlaceholdersInUsername (0.00s)
basicauth_test.go:43: expected an account for the username as configured, got accounts ["alice-"]
--- FAIL: TestBasicAuthProvisionRejectsBracedPasswordInsteadOfRewritingIt (0.00s)
basicauth_test.go:98: expected provisioning to fail for a password with literal braces, instead it accepted the rewritten password "i\xb7\x9f"
FAIL
expected: unknown {...} in credentials survive as literal config data, real placeholders like {env.*} still expand
Confirmed on current master. HTTPBasicAuth.Provision in modules/caddyhttp/caddyauth/basicauth.go runs repl.ReplaceAll on both acct.Username and acct.Password before anything else happens to them, so any literal { or } the replacer does not recognize gets expanded to empty rather than left alone.
This is the same bug class already fixed in the header handler (#4880) and in the response headers path (#8014), both of which moved to repl.ReplaceKnown so unrecognized placeholders survive as literal text. Basic auth looks like the one remaining call site still on ReplaceAll.
Since the account list is parsed once at provision time and stored in a plain map, switching those two lines to repl.ReplaceKnown should carry the same fix here with no behavior change for real placeholders like {env.*}, only for the unrecognized-brace case this issue describes.
Disclosure: I used AI assistance to trace this call site and draft this comment; the code read and conclusion are my own.
Activity
thejdubb02 commentedon Sep 25, 2026
Confirmed on current master. HTTPBasicAuth.Provision in modules/caddyhttp/caddyauth/basicauth.go runs repl.ReplaceAll on both acct.Username and acct.Password before anything else happens to them, so any literal { or } the replacer does not recognize gets expanded to empty rather than left alone.
This is the same bug class already fixed in the header handler (#4880) and in the response headers path (#8014), both of which moved to repl.ReplaceKnown so unrecognized placeholders survive as literal text. Basic auth looks like the one remaining call site still on ReplaceAll.
Since the account list is parsed once at provision time and stored in a plain map, switching those two lines to repl.ReplaceKnown should carry the same fix here with no behavior change for real placeholders like {env.*}, only for the unrecognized-brace case this issue describes.
Disclosure: I used AI assistance to trace this call site and draft this comment; the code read and conclusion are my own.