extproc: always redact credential header mutations in debug log - #2435
Merged
nacx merged 3 commits intoJul 31, 2026
Conversation
The "request headers processed" debug log only ran header-mutation redaction when Server.enableRedaction was on. With debug logging on but redaction off (the aigw run default), the upstream filter's injected Authorization (the backend API key) was logged in cleartext even though the incoming authorization header was already redacted by filterSensitiveHeadersForLogging. This was inconsistent with the RequestBody phase, whose redactRequestBodyResponse always redacts header mutations and only gates body-content redaction on the flag. Align the RequestHeaders phase to the same pattern: redact header mutations whenever debug logging is on, independent of enableRedaction; gate only body content on the flag via a new redactBody parameter on redactProcessingResponseRequestHeaders. A nil-response guard is added matching redactRequestBodyResponse. Note: Envoy's own [http] and [ext_proc] debug logs still emit the raw Authorization header/proto and are outside extproc's control; those require Envoy log-level tuning, not addressed here. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: liuhy <liuhongyu@apache.org>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2435 +/- ##
==========================================
+ Coverage 84.86% 84.92% +0.06%
==========================================
Files 154 154
Lines 22419 22423 +4
==========================================
+ Hits 19026 19043 +17
+ Misses 2237 2224 -13
Partials 1156 1156 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nacx
approved these changes
Jul 30, 2026
nacx
enabled auto-merge (squash)
July 30, 2026 10:59
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
sivanantha321
pushed a commit
to sivanantha321/ai-gateway
that referenced
this pull request
Jul 31, 2026
…yproxy#2435) **Description** The "request headers processed" debug log only ran header-mutation redaction when Server.enableRedaction was on. With debug logging on but redaction off (the aigw run default), the upstream filter's injected Authorization (the backend API key) was logged in cleartext, even though the incoming authorization header was already redacted by filterSensitiveHeadersForLogging. This was inconsistent with the RequestBody phase, whose redactRequestBodyResponse always redacts header mutations and only gates body-content redaction on the flag. This change aligns the RequestHeaders phase to the same pattern: redact header mutations whenever debug logging is on, independent of enableRedaction, and gate only body content on the flag via a new redactBody parameter on redactProcessingResponseRequestHeaders. A nil-response guard is added matching redactRequestBodyResponse. **Special notes for reviewers (if applicable)** - No behavior change to the response sent to Envoy; redaction only touches the logContent copy used for the debug log. Process-level tests assert on the returned resp, not log content, so they are unaffected. - Verified live: with AIGW_DEBUG=true and enableRedaction off, the upstream Authorization mutation now logs as [REDACTED] while the actual response sent upstream still carries the real key. - Out of scope: Envoy's own [http] and [ext_proc] debug logs still emit the raw Authorization header / proto and are outside extproc's control; those require Envoy log-level tuning, not addressed here. **Related Issues/PRs (if applicable)** Adjacent to but distinct from envoyproxy#2428 (which covers request body content redaction for the 7 passthrough endpoints). This PR covers a different leak surface: the backend credential injected into the request-headers header mutation by the extproc upstream filter. Co-Authored-By: Claude <noreply@anthropic.com> Partially addresses envoyproxy#2436 (extproc Go side; Envoy-side leak points remain). Signed-off-by: liuhy <liuhongyu@apache.org> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
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
The "request headers processed" debug log only ran header-mutation redaction when Server.enableRedaction was on. With debug logging on but redaction off (the aigw run default), the upstream filter's injected Authorization (the backend API key) was logged in cleartext, even though the incoming authorization header was already redacted by filterSensitiveHeadersForLogging.
This was inconsistent with the RequestBody phase, whose redactRequestBodyResponse always redacts header mutations and only gates body-content redaction on the flag. This change aligns the RequestHeaders phase to the same pattern: redact header mutations whenever debug logging is on, independent of enableRedaction, and gate only body content on the flag via a new redactBody parameter on redactProcessingResponseRequestHeaders.
A nil-response guard is added matching redactRequestBodyResponse.
Special notes for reviewers (if applicable)
Related Issues/PRs (if applicable)
Adjacent to but distinct from #2428 (which covers request body content redaction for the 7 passthrough endpoints). This PR covers a different leak surface: the backend credential injected into the request-headers header mutation by the extproc upstream filter.
Co-Authored-By: Claude noreply@anthropic.com
Partially addresses #2436 (extproc Go side; Envoy-side leak points remain).