fix(logging): mask *-api-key headers in request-log pipeline - #13401
Merged
diegosouzapw merged 1 commit intoSep 15, 2026
Merged
diegosouzapw merged 1 commit into
diegosouzapw merged 1 commit into
Conversation
…uzapw#13273) maskSensitiveHeaders in requestLogger.ts matched a hardcoded substring list that missed several real upstream credential headers: - x-goog-api-key (Gemini / Vertex) - api-key (Azure OpenAI) - xi-api-key (ElevenLabs proxy) These passed through completely unmasked into the request-log pipeline. Fix: 1. Normalize header names by stripping hyphens before matching (compacted comparison), so the "apikey" catch-all in sensitiveKeys matches every current and future *-api-key spelling. 2. Add xi-api-key to SENSITIVE_KEYS in logPayloads.ts for body-level redaction via protectPayloadForLog / redactPayload. Regression tests cover all three previously-missing headers plus the existing x-api-key (Anthropic) path and the x-ratelimit- whitelist. Fixes diegosouzapw#13273
diegosouzapw
merged commit Sep 15, 2026
8bad85f
into
diegosouzapw:release/v3.8.51
8 of 16 checks passed
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…uzapw#13273) (diegosouzapw#13401) Masks every `*-api-key` header spelling (`x-goog-api-key`, `api-key`, `xi-api-key`) in the request-log pipeline by matching on the hyphen-compacted key, and adds `xi-api-key` to the payload redaction set (diegosouzapw#13273). The new test drives the real `createRequestLogger` / `protectPayloadForLog` paths. Validated in one consolidated batch of this series (37 PRs boarded together on `release/v3.8.51`): `typecheck:core`, `check:open-sse-typecheck` and `check:dashboard-typecheck` clean; ESLint clean on every changed file; file-size, complexity, cognitive-complexity, changelog-integrity, docs-counts, docs-sync and migration-numbering gates green (only the pre-existing `open-sse/utils/stream.ts` file-size red remains, inherited from the base); 3,743 focused `node:test` cases plus 34 vitest cases green. Thanks @KooshaPari!
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.
Summary
maskSensitiveHeadersinopen-sse/utils/requestLogger.tsmatched a hardcoded substring list that missed several real upstream credential headers:x-goog-api-keyapi-keyxi-api-keyx-api-keyThese passed through verbatim into the request-log pipeline (
logTargetRequest→getPipelinePayloads).Fix
1. Compact header matching (
open-sse/utils/requestLogger.ts):Strip hyphens from both the header key and each candidate before comparing, so the
"apikey"catch-all insensitiveKeysmatches every current and future*-api-keyspelling:2. Add
xi-api-keytoSENSITIVE_KEYS(src/lib/logPayloads.ts):Defense-in-depth for body-level redaction via
protectPayloadForLog/redactPayload.Tests
New regression test file
tests/unit/request-logger-header-mask-apikey-13273.test.tswith 7 tests covering:x-goog-api-key(Gemini) — previously unmasked, now maskedapi-key(Azure OpenAI) — previously unmasked, now maskedxi-api-key(ElevenLabs) — previously unmasked, now maskedx-api-key(Anthropic) — still masked (regression guard)x-ratelimit-headers — still NOT masked (whitelist preserved)protectPayloadForLogredactsxi-api-keyandx-goog-api-keyin body payloadsAll existing tests pass:
request-log-payloads(26/26),request-logger-bounded-idempotence(6/6).Related
Fixes #13273