Description
The authenticate_with_browser_redirect() function logs the received API key value directly in the error message when the key format validation fails.
Context
- File:
cli/src/apikey_auth.rs:277 (approximate, in authenticate_with_browser_redirect)
- Component: Browser-based API key authentication flow
Current Behavior
When the received key does not start with stkpk_api, the error message includes the full received value:
Err(format!("Invalid API key format received: {}", clean_key))
This means:
- If a real API key is somehow received in a slightly malformed way (e.g., extra prefix), it gets logged in plaintext
- If logging is configured at WARN level or below, the key appears in log files, systemd journal, or monitoring systems
- The key could appear in crash reports or error tracking systems
Expected Behavior
The error message should redact the sensitive value:
- Err(format!("Invalid API key format received: {}", clean_key))
+ Err(format!(
+ "Invalid API key format: received {} chars, expected prefix \"stkpk_api\"",
+ clean_key.len()
+ ))
Or if some prefix info is needed for debugging:
Err(format!(
"Invalid API key format: key starts with \"{}\"",
&clean_key[..clean_key.len().min(8)]
))
Impact
- Severity: Medium
- Affected users: Anyone using ACP agent auth via browser redirect (
authenticate_with_browser_redirect)
- Risk: Credential exposure in logs, monitoring, or error tracking systems
Environment
- Affects all versions with the browser redirect auth flow
Positively — happy to submit a PR if this is welcome.
Description
The
authenticate_with_browser_redirect()function logs the received API key value directly in the error message when the key format validation fails.Context
cli/src/apikey_auth.rs:277(approximate, inauthenticate_with_browser_redirect)Current Behavior
When the received key does not start with
stkpk_api, the error message includes the full received value:This means:
Expected Behavior
The error message should redact the sensitive value:
Or if some prefix info is needed for debugging:
Impact
authenticate_with_browser_redirect)Environment
Positively — happy to submit a PR if this is welcome.