Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit c4ae1dd

Browse files
greynewellclaude
andcommitted
fix: redact secrets from auth debug logs
The callback URL contains key=smsk_... and state=<token> — both secrets. Logging r.URL.String() or raw state values would expose them in CI logs, bug reports, and support tickets. - Callback log now prints only the path and param names (never values) - State mismatch log drops the raw token values entirely - Dashboard URL log shows port only; state is marked <redacted> Co-Authored-By: Grey Newell <greyshipscode@gmail.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 36c5743 commit c4ae1dd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cmd/auth.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,18 @@ func authLoginBrowser(cfg *config.Config) (string, error) {
139139

140140
mux := http.NewServeMux()
141141
mux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
142-
logFn("[debug] auth: callback received: %s", r.URL.String())
142+
// Log the callback path and which query params are present, but never
143+
// their values — key and state are secrets.
144+
q := r.URL.Query()
145+
params := make([]string, 0, len(q))
146+
for k := range q {
147+
params = append(params, k)
148+
}
149+
logFn("[debug] auth: callback received: %s (params: %v)", r.URL.Path, params)
143150

144151
gotState := r.URL.Query().Get("state")
145152
if gotState != state {
146-
logFn("[debug] auth: state mismatch — got %q, expected %q", gotState, state)
153+
logFn("[debug] auth: state mismatch (CSRF check failed)")
147154
http.Error(w, "Invalid state parameter", http.StatusForbidden)
148155
resultCh <- callbackResult{err: fmt.Errorf("state mismatch (possible CSRF)")}
149156
return
@@ -182,7 +189,7 @@ func authLoginBrowser(cfg *config.Config) (string, error) {
182189
}()
183190

184191
dashURL := fmt.Sprintf("%s?port=%d&state=%s", config.EffectiveCLIAuthURL(), port, state)
185-
logFn("[debug] auth: dashboard URL: %s", dashURL)
192+
logFn("[debug] auth: opening dashboard (port=%d, state=<redacted>)", port)
186193
fmt.Println("Opening your browser to sign in...")
187194
fmt.Printf(" %s\n\n", dashURL)
188195
fmt.Println("Waiting for authentication (this will timeout in 2 minutes)...")

0 commit comments

Comments
 (0)