shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

Proposal: Mask credential headers in logging plugins by default

Open SouthwestAsiaFloat opened this issue 3 weeks ago • 1 comments

Proposal: Mask credential headers in logging plugins by default

Metadata

  • Change Name: logging-credential-headers
  • External Issue ID: https://github.com/apache/shenyu/issues/8446
  • State: proposed; specification confirmation is recorded separately.

Background

ShenYu logging plugins record request and response headers. At upstream 9dd9a12fb, the shared LogCollectUtils.getHeaders serializes values verbatim. loggingConsole has a separate text-formatting path with the same default exposure. Existing keyword masking requires per-rule opt-in and keywords, so an operator can unintentionally send authentication credentials to log sinks. A request with Authorization: Bearer secret should instead log Authorization: *** without changing the header forwarded to its destination.

Goals

  • Protect six well-known credential headers by default on requests and responses.
  • Apply a consistent policy to the shared pipeline and loggingConsole, including error paths.
  • Allow operators to extend the protected names or explicitly disable this policy.
  • Preserve HTTP traffic and existing rule-based keyword/body masking.

Scope

Plugin-global JSON configuration; header-name matching and log formatting; per-request configuration capture; Console configuration lifecycle; regression tests and the durable logging-credential-headers contract.

Non-Goals

URI, query-string, body or arbitrary exception-message credential discovery; new logging destinations; changing sampling, body limits or delivery guarantees; a dashboard form redesign; historical log cleanup; changing authentication.

Key Constraints

  • Active published artifacts belong in linked Proposal, Design and Implement issues.
  • Use the existing plugin config JSON and Admin-to-gateway synchronization path.
  • Preserve public plugin names, existing method signatures and forwarding behavior.
  • This is full scope because defaults and public configuration semantics change.

Related Specs Analysis

No existing durable capability specs are present in baseline 9dd9a12fb. The source request is #8446. Shared entry points are AbstractLoggingPlugin.doExecute, LogCollectUtils.getHeaders and LoggingServerHttpResponse; Console uses LoggingConsolePlugin and LoggingConsolePluginDataHandler. Existing sampling, body-limit and keyword-desensitization tests define compatibility constraints. The unmerged candidate e63c9ea14bebd22a63a6a1e94e5c56a5050ca358 implements these proposed semantics; it is evidence for review, not an approved baseline.

Existing Assumptions Impact

Operators may currently rely on raw credential values in access logs; the new secure default deliberately changes that behavior. An explicit configuration switch restores raw header logging under this policy, while any existing rule masking can still apply. Missing settings must remain secure for existing plugin JSON. The gateway continues to read synchronized in-memory config, not the DB.

Question Convergence Check

No genuine unresolved product decision was identified while drafting. This is not a declaration of approval. Any subsequently discovered unresolved decision must be recorded as a blocking typed QUESTION before dependent work proceeds.

Capabilities

Credential header masking with case-insensitive names, additive configuration, explicit opt-out, consistent per-request policy and unchanged HTTP forwarding.

Impact

Existing operators gain masking without updating rules or stored JSON. Log consumers see *** instead of credential values. Ordinary headers keep their existing format. No database columns, seed records or upgrade SQL are required.

SouthwestAsiaFloat avatar Nov 12 '26 04:11 SouthwestAsiaFloat

Agent: Codex Type: SPEC ID: SPEC-8460001 Status: confirmed Scope: logging-credential-headers Links:

  • Proposal Issue: https://github.com/apache/shenyu/issues/8460
  • Design Issue: N/A
  • Implement Issue: N/A
  • Related Comments: N/A
  • PR: N/A

Requirement: Credential header masking in logging plugins

Logging plugins MUST replace the complete logged value of Authorization, Proxy-Authorization, Cookie, Set-Cookie, ShenYu-Authorization and token with a single *** by default, matching header names case-insensitively. The policy MUST apply to request and response headers, including headers captured on error paths, in both the shared logging pipeline and loggingConsole. Plugin-global maskCredentialHeaders MUST default to true; explicit false MUST disable this policy. Plugin-global maskedHeaders MUST add names to the built-in list rather than replace it. Missing or null settings and an empty additional list MUST retain built-in protection. Configured names MUST be trimmed and matched case-insensitively; null and blank entries MUST be ignored. Each request MUST retain its captured policy across configuration replacement, and subsequent requests MUST use the updated policy. Masking MUST NOT modify forwarded HTTP headers or change existing rule-based keyword/body masking. Malformed JSON and wrong JSON types remain subject to existing deserialization behavior, without a new fallback guarantee.

Scenario: Defaults without rule masking

  • WHEN a request is logged with credential header masking settings omitted and rule keyword masking disabled
  • THEN the six built-in credential header names are masked in logged requests and responses in the common and Console paths

Scenario: Mixed case and multiple values

  • WHEN a protected header has mixed casing and multiple values
  • THEN the complete logged value is one *** and none of the original values remain in that header field

Scenario: Ordinary and empty headers

  • WHEN headers contain unprotected names or the header collection is empty
  • THEN ordinary values retain their existing format and an empty collection formats without failure

Scenario: Additional names and null entries

  • WHEN maskedHeaders contains X-Api-Key, whitespace-padded names, null and blank entries
  • THEN custom names are trimmed and matched without case sensitivity, null/blank entries are ignored and built-in protection remains active

Scenario: Missing and null configuration

  • WHEN maskCredentialHeaders is missing or null and maskedHeaders is missing, null or empty
  • THEN the built-in deny-list remains enabled

Scenario: Explicit opt-out

  • WHEN maskCredentialHeaders is false
  • THEN this policy leaves both built-in and custom header values unchanged, while existing rule keyword/body masking can still apply

Scenario: Configuration reload during a request

  • WHEN configuration changes after a request enters a logging plugin
  • THEN that request uses its captured policy for both directions, subsequent requests use the new policy and plugin-specific overrides do not affect other plugin IDs

Scenario: Normal and error paths preserve traffic

  • WHEN normal or error processing captures credential headers
  • THEN logged header fields are masked under the captured policy and live HTTP header values remain unchanged

Scenario: Console lifecycle

  • WHEN a Console plugin with a cached masking override is disabled or removed
  • THEN its cached override is removed and an absent configuration falls back to secure defaults

Durable Intent

{
  "version": 1,
  "intent": "OPERATIONS",
  "operations": [
    {
      "id": "SPEC-8460001-OP-01",
      "kind": "ADDED",
      "capability": "logging-credential-headers",
      "path": "issue-spec/specs/logging-credential-headers/spec.md",
      "new_requirement": "Credential header masking in logging plugins",
      "projection": {
        "source": "current-spec"
      }
    }
  ]
}

Confirmation record

The contributor explicitly confirmed this behavior in the working conversation on 2026-11-12 and authorized publishing the confirmed SPEC. This records contributor confirmation, not maintainer review or merge approval.

SouthwestAsiaFloat avatar Nov 12 '26 04:11 SouthwestAsiaFloat