mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Keep credentials out of app-server logs (#39993)
## Why App-server logs can be persisted or included in submitted diagnostics, so credentials used by model providers, authentication refreshes, and attestation requests must not appear in diagnostic output. ## What changed - Add `RedactedString`, which preserves serialization and string access while replacing debug output with `<redacted>`. - Use it for model-provider bearer tokens, header and query values, authentication command arguments, and attestation tokens. - Avoid logging JSON-RPC error payloads and parser or authentication errors that may echo credentials; retain safe context such as error codes and categories. ## Testing - Add an app-server regression test that exercises provider credentials, refreshed authentication tokens, and attestation tokens, then verifies none appear in persisted SQLite or submitted diagnostic logs. GitOrigin-RevId: 8c50408adf94d93847658b1320682cf3b637d2cc
This commit is contained in:
1 parent
45a3edc02a
commit
79b7606803
36 files changed
+446
-108
No files matched your search
@@ -49,10 +49,9 @@ impl ExternalAuthBridge {
|
||||
std::io::Error::other(format!("auth refresh request canceled: {err}"))
|
||||
})?;
|
||||
result.map_err(|err| {
|
||||
std::io::Error::other(format!(
|
||||
"auth refresh request failed: code={} message={}",
|
||||
err.code, err.message
|
||||
))
|
||||
// Don't log err.message because it may contain a token.
|
||||
let code = err.code;
|
||||
std::io::Error::other(format!("auth refresh request failed: code={code}"))
|
||||
})?
|
||||
}
|
||||
Err(_) => {
|
||||
@@ -64,13 +63,17 @@ impl ExternalAuthBridge {
|
||||
}
|
||||
};
|
||||
|
||||
let response: ChatgptAuthTokensRefreshResponse =
|
||||
serde_json::from_value(result).map_err(std::io::Error::other)?;
|
||||
// Don't propagate parser error messages because they may contain a token.
|
||||
let response: ChatgptAuthTokensRefreshResponse = serde_json::from_value(result)
|
||||
.map_err(|_| std::io::Error::other("invalid auth refresh response"))?;
|
||||
let auth = CodexAuth::from_external_chatgpt_tokens(
|
||||
response.access_token.as_str(),
|
||||
response.chatgpt_account_id.as_str(),
|
||||
response.chatgpt_plan_type.as_deref(),
|
||||
)?;
|
||||
)
|
||||
.map_err(|err| {
|
||||
std::io::Error::new(err.kind(), "auth refresh returned invalid credentials")
|
||||
})?;
|
||||
*self
|
||||
.auth
|
||||
.write()
|
||||
|
||||
Reference in new issue
Block a user