shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[Feature] Mask credential headers in logging plugins by default

Open Aias00 opened this issue 3 weeks ago • 1 comments

Feature Request

Mask well-known credential headers in logging plugins by default.

Is your feature request related to a problem? Please describe

LogCollectUtils.getHeaders serializes every request and response header verbatim:

https://github.com/apache/shenyu/blob/9dd9a12fb/shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectUtils.java#L56-L60

It is used for request headers in AbstractLoggingPlugin and for response headers in LoggingServerHttpResponse. Masking only happens when a rule enables maskStatus and lists keywords (AbstractLoggingPlugin L88-L97). With default settings, loggingConsole, loggingKafka, loggingElasticSearch and the other logging plugins ship values such as Authorization, Proxy-Authorization, Cookie, Set-Cookie, the sign plugin's ShenYu-Authorization and the JWT token header to the log sink unchanged.

Describe the solution you'd like

Apply a default deny-list of credential headers before serialization. The masked value replaces the header value, for example ***. Allow the list to be extended or disabled in the plugin configuration, and keep the existing keyword-based body masking as it is.

Describe alternatives you've considered

Requiring every operator to configure keywords on every logging rule. This works today but is easy to miss, and a missing rule leaks credentials into the log sink.

Additional context

Applies to master @ 9dd9a12fb.

Aias00 avatar Nov 11 '26 09:11 Aias00

/assign

SouthwestAsiaFloat avatar Nov 11 '26 11:11 SouthwestAsiaFloat