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:
andrewgu-oai authored and copyberry committed 2026-08-21 19:04:32 +00:00
1 parent 45a3edc02a
commit 79b7606803
36 files changed
+446 -108

No files matched your search

+3 -2
View File
@@ -519,6 +519,7 @@ mod tests {
use codex_protocol::openai_models::ModelInfo;
use codex_protocol::openai_models::ModelsResponse;
use codex_protocol::protocol::SessionSource;
use codex_utils_redacted_string::RedactedString;
use pretty_assertions::assert_eq;
use serde_json::json;
use wiremock::Mock;
@@ -821,7 +822,7 @@ mod tests {
"--skip",
counter.to_str().expect("counter path should be UTF-8"),
]
.map(str::to_string),
.map(RedactedString::from),
),
timeout_ms: NonZeroU64::new(10_000).expect("timeout should be non-zero"),
}),
@@ -1169,7 +1170,7 @@ mod tests {
.await;
let mut provider_info = provider_for(server.uri());
provider_info.experimental_bearer_token = Some("provider-token".to_string());
provider_info.experimental_bearer_token = Some("provider-token".into());
let provider = create_model_provider(
provider_info,
Some(AuthManager::from_auth_for_testing(