[CRED-2625] Redact Authorization (Bearer) header in debug logRequest#4168
Draft
luczhou wants to merge 1 commit into
Draft
[CRED-2625] Redact Authorization (Bearer) header in debug logRequest#4168luczhou wants to merge 1 commit into
luczhou wants to merge 1 commit into
Conversation
isomorphic-fetch.ts's logRequest method masks DD-API-KEY and DD-APPLICATION-KEY values before logging the captured request, but the Authorization header (Bearer tokens — delegated tokens, PATs) falls through and gets logged verbatim. Any caller running with debug=true and access-token auth leaks the bearer to the global logger. Surfaced cross-language by terraform-provider-datadog#3757, which is the first Terraform code path to use PAT (Bearer) auth via the Go SDK. Verified the same gap exists here in TS. Add a third allowlist entry that masks the Authorization header value with `x`s, matching the existing api/app key handling. Test exercises logRequest directly with all three credentials set and asserts none of the original values appear in the captured log output. Refs: CRED-2625, terraform-provider-datadog#3757 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
isomorphic-fetch.ts'slogRequestmethod (packages/datadog-api-client-common/http/isomorphic-fetch.ts:168-200) masksDD-API-KEYandDD-APPLICATION-KEYvalues withxs before logging the captured request, but theAuthorizationheader (Bearer tokens — delegated tokens, PATs) falls through and gets logged verbatim. Any caller running withdebug = trueand access-token auth leaks the bearer to the global logger.Surfaced cross-language by terraform-provider-datadog#3757, which is the first Terraform code path to use PAT (Bearer) auth via the Go SDK. The same gap exists here in TS.
Tracking ticket: CRED-2625.
Changes
packages/datadog-api-client-common/http/isomorphic-fetch.ts: add a third allowlist entry that masks theAuthorizationheader value withxs, matching the existing api/app-key handling shape.tests/api/log-redaction.test.ts: new testlogRequest masks Authorization Bearer token— driveslogRequestdirectly with all three credentials set on the request context and asserts none of the original credential values appear in the capturedlogger.debugoutput, and that each is replaced by anx-string of the same length.Cross-language
Related work tracked under CRED-2625:
datadog-api-client-goPR #4098 — same fix shape (redactContextAccessTokeninCallAPIdebug dump).datadog-api-client-rubyPR (forthcoming) — same fix shape (addAuthorizationtosanitize_request_header'skeys_to_redact).datadog-api-client-javaGH issue (forthcoming) — wider gap. JerseyLoggingFeature.PAYLOAD_ANYhas no header redaction at all, so api/app keys and bearer leak there.datadog-api-client-python— no equivalent gap (no request-header logging inrest.j2).Testing
yarn jest-test --testPathPattern=log-redactionpassesyarn jest-testfull suite (run by CI)🤖 Generated with Claude Code