Design: Default credential header masking across logging plugins
Design: Mask credential headers in logging plugins by default
Question Convergence Check
- Proposal Issue: #8460
- Source SPEC: https://github.com/apache/shenyu/issues/8460#issuecomment-6814335706
- The contributor explicitly confirmed the SPEC behavior on 2026-11-12. No maintainer approval is claimed.
- No unresolved product questions were identified.
Current Implementation Locations
All paths below are relative to shenyu-plugin/shenyu-plugin-logging/.
- shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/AbstractLoggingPlugin.java:doExecute creates the log and decorators.
- shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectUtils.java:getHeaders formats shared headers.
- shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/body/LoggingServerHttpResponse.java:appendResponse and logError capture response headers.
- shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/config/GenericGlobalConfig.java carries inherited plugin settings.
- shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/handler/AbstractLogPluginDataHandler.java:handlerPlugin deserializes and caches global config.
- shenyu-plugin-logging-console/src/main/java/org/apache/shenyu/plugin/logging/console/LoggingConsolePlugin.java:getHeaders formats Console output independently.
- shenyu-plugin-logging-console/src/main/java/org/apache/shenyu/plugin/logging/console/handler/LoggingConsolePluginDataHandler.java receives Console config updates.
Involved Modules
logging-common owns reusable policy and the shared request/response integration. logging-console reuses the policy while retaining its text output and collector-free path. Existing sink-specific configuration classes inherit GenericGlobalConfig. The durable contract belongs at issue-spec/specs/logging-credential-headers/spec.md.
Impact Scope
One SPEC, SPEC-8460001, describes the complete observable header policy. One TASK, TASK-8461001, covers policy, both logging paths, configuration lifecycle, tests and durable documentation. No PROCESS decomposition is needed for this sequential work.
Unaffected Modules
Admin persists the existing opaque plugin config JSON and publishes existing change events. Data-sync channels deliver PluginData unchanged. Gateway handlers parse the added fields through existing config classes. Starters, public SPI, plugin names, authentication, selectors and rule schemas remain unchanged. No schema/seed metadata changes require SQL updates for any supported dialect. The existing plugin configuration/API can carry these JSON fields without new shared DTO members; dashboard-specific input widgets are outside this change.
Search Entry Points / Key Files
Run rg for maskCredentialHeaders, maskedHeaders, LogCollectUtils.getHeaders, setRequestHeader and setResponseHeader within the logging plugin modules. Read GenericGlobalConfig, AbstractLoggingPlugin, LoggingServerHttpResponse and LoggingConsolePlugin together; Console does not extend AbstractLoggingPlugin.
Risk Hotspots
- Independent Console formatting must not bypass defaults or mutate live headers.
- Request/response logging may occur at different times, so lazy suppliers must capture a stable policy rather than read the latest global config.
- Protected multi-value headers must not retain a second unmasked value.
- Disabled/removed Console plugins must discard cached overrides.
- Null and empty optional settings must not remove the default deny-list.
- Explicit opt-out changes only this policy, not existing rule masking.
Candidate Plans
- Require per-rule keywords: retains the current easy-to-miss setup requirement.
- Mask in each sink client: duplicates behavior and misses Console's independent path.
- Apply one shared policy at header formatting boundaries: selected; protects both paths before credentials are serialized into log content.
Decisions
- Built-in lowercase names: authorization, proxy-authorization, cookie, set-cookie, shenyu-authorization, token. Replacement: one *** per matched header.
- maskCredentialHeaders is a boolean defaulting to true. Explicit false disables built-in and additional-name masking. Missing/null JSON retains the default.
- maskedHeaders is an additive JSON array of names, default empty. Matching uses Locale.ROOT lowercase and trims configured names; null/blank entries are ignored.
- Capture an immutable name set at request entry and pass it to both formatting paths. Configuration replacement affects subsequent requests.
- Keep the one-argument getHeaders and existing response constructors with secure defaults; add overloads for a captured policy without removing signatures.
- Continue existing body and keyword masking independently. No new subscription, worker, queue or buffer ownership is introduced by header masking.
- Wrong JSON types and malformed JSON retain existing deserialization behavior; this change does not introduce an Admin validation contract or fallback promise.
Rejected Alternatives
Do not mutate HttpHeaders to mask logs: that would change authentication or cookie behavior on the real request/response. Do not replace the default list with an operator list: an empty list must not accidentally remove default protection.
Test Strategy and Acceptance Criteria
The implementation TASK verifies SPEC-8460001 using:
- LogCollectUtilsTest: six defaults, mixed case, multiple values, empty headers, ordinary header joining, additive names, null/blank entries, explicit opt-out, missing/null JSON and immutable captured policy.
- AbstractLoggingPluginBodyLimitTest: request/response masking across a config update on normal/error paths, next-request opt-out, plugin-ID isolation and unchanged live headers.
- LoggingConsolePluginTest: equivalent text output on normal/error paths, configuration reload, unchanged live headers and disable/removal cleanup.
- Existing logging tests: sampling, body limits, keyword masking, decorators and collector behavior continue to pass.
The verification commands below provide the observed evidence. The 175 passing tests cover common, Console and desensitization modules; they are not all sink integration tests. Final acceptance also requires published linked artifacts, confirmed SPECs and review under repository policy.
Rollout / Rollback Notes
Deploy the updated gateway jars; omitted fields enable masking immediately. Add custom names through each logging plugin's global config as required. Explicit maskCredentialHeaders=false opts out, with credential exposure as the intended consequence. Rolling back the code restores previous raw default logs. No data migration or stored-config backfill is required. Existing exposed logs are not modified. Keep ordinary rule masking and sink configuration intact.
Confirmation Checklist
- [x] Published Proposal/SPEC links replace local references.
- [x] SPEC behavior was explicitly confirmed by the contributor.
- [x] No unresolved blocking product questions identified.
- [x] TASK-8461001 has Covers and a canonical Related Comments link to SPEC-8460001.
- TASK: https://github.com/apache/shenyu/issues/8461#issuecomment-6814364380
- Implementation: #8462; proposed by PR #8463.
Verification commands
On JDK 17, the following passed with 175 tests, zero failures/errors/skips and Checkstyle enabled:
./mvnw -pl shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console -am test '-Dtest=org.apache.shenyu.plugin.logging.**.*Test' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.javadoc.skip=true -Djacoco.skip=true
The full reactor build, Docker integration tests and live sink integration tests were not run.
Agent: Codex Type: TASK ID: TASK-8461001 Status: done Scope: logging-credential-headers Links:
- Proposal Issue: https://github.com/apache/shenyu/issues/8460
- Design Issue: https://github.com/apache/shenyu/issues/8461
- Implement Issue: https://github.com/apache/shenyu/issues/8462
- Related Comments: https://github.com/apache/shenyu/issues/8460#issuecomment-6814335706
- PR: https://github.com/apache/shenyu/pull/8463
Task: Implement and verify default credential header masking
Implemented in commit 3680aaafaf5c7e1c58da04ec63199da4474853e9, proposed by PR #8463. The shared and Console paths implement the contributor-confirmed SPEC. The generated durable spec passed exact baseline/subject projection checks, and 175 logging tests passed on JDK 17 with Checkstyle. Apache RAT and git diff --check passed. No full reactor, Docker or live-sink integration run is claimed.
Implementation Checklist
- [x] Implement secure defaults, additive names and explicit opt-out in inherited global configuration.
- [x] Capture the header policy once per request and use it for request, response and error formatting.
- [x] Integrate Console global config reload, disable and removal with the shared cache.
- [x] Verify mixed case, multiple values, defaults, null entries, opt-out, reload and unchanged live headers.
- [x] Verify plugin-ID policy isolation with testHeaderPoliciesAreIsolatedByPluginId.
- [x] Retain existing keyword/body masking behavior and run the affected logging suite on JDK 17.
- [x] Publish and link the genuine SPEC/TASK identities; apply/check its durable projection against the actual candidate.
- [x] Record Checkstyle/RAT/test evidence, unrun checks and any subsequent scope corrections.
Execution Planning
- Owned modules / write areas:
- shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/**
- shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-console/**
- issue-spec/specs/logging-credential-headers/spec.md
- Shared touchpoints:
- GenericGlobalConfig
- LogCollectUtils
- AbstractLogPluginDataHandler.getPluginGlobalConfigMap()
- Dependency / interface assumptions:
- Published Design and confirmed SPEC with a canonical comment URL
- Coupling class: Shared policy and independent Console formatting must stay consistent
- Recommended execution mode: Direct sequential work by the current agent; no PROCESS required
- Complexity / split guidance: One coherent change; no public SPI removal or SQL migration
Covers
- SPEC-8460001