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

+6 -6
View File
@@ -82,11 +82,8 @@ async fn request_attestation_header_value_with_timeout(
let result = match timeout(timeout_duration, rx).await {
Ok(Ok(Ok(result))) => result,
Ok(Ok(Err(err))) => {
warn!(
code = err.code,
message = %err.message,
"attestation generation request failed"
);
// Don't log err.message because it may contain a token.
warn!(code = err.code, "attestation generation request failed");
return app_server_attestation_header_value(
AppServerAttestationStatus::RequestFailed,
/*token*/ None,
@@ -118,7 +115,10 @@ async fn request_attestation_header_value_with_timeout(
Some(&response.token),
),
Err(err) => {
warn!("failed to deserialize attestation generation response: {err}");
warn!(
error_category = ?err.classify(),
"failed to deserialize attestation generation response"
);
app_server_attestation_header_value(
AppServerAttestationStatus::MalformedResponse,
/*token*/ None,