apache / apache/shenyu

[BUG] — `LoggingConsolePlugin`: per-request `new KeyWordMatch(...)` (→ `Pattern.compile`) + `static dataDesensitizeAlg` reassigned per request (race/cross-request leak)

Open
#6,802 1 comment 0 reactions 0 assignees View on GitHub
priority: medium type: performance
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: Medium-High
- files: `shenyu-plugin-logging-console/.../LoggingConsolePlugin.java:80` (`private static String dataDesensitizeAlg = ...`), `:88` (`new KeyWordMatch(Collections.emptySet())` always), `:95` (`new KeyWordMatch(keywordSets)` + `dataDesensitizeAlg = ...` when desensitization on), `:132,:140` (use). `KeyWordMatch.java:46` (`Pattern.compile(sb.toString())` in constructor)
- description: (a) `doExecute` constructs a fresh `KeyWordMatch` on every request → `Pattern.compile` per request whenever logging-console is enabled. (b) `dataDesensitizeAlg` is a `static` field reassigned per request → concurrent requests overwrite each other's algorithm choice and pass the wrong alg to `DataDesensitizeUtils` for a different request's body (data race / cross-request desensitization leak — also a correctness defect).
- impact: Per-request regex compile; cross-request algorithm leakage.
- suggested_fix: Cache `KeyWordMatch` per rule-handle (rule-keyed like `CACHED_HANDLE`); make `dataDesensitizeAlg` an instance field or pass it through the decorator chain.
- confidence: High
- related_existing: PERF-26 covers `AbstractLoggingPlugin` allocation; this is the separate `LoggingConsolePlugin` class with its own per-request `KeyWordMatch` + the static-field race. #6511 (logging desensitization leak across concurrent requests) is the AbstractLoggingPlugin path — different class.

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at doExecute in LoggingConsolePlugin.java around lines 80, 88, 95, 132, and 140, then read KeyWordMatch.java around line 46 and the existing CACHED_HANDLE usage. Verify that rule-specific matching is reused rather than compiled per request and that concurrent requests cannot share the wrong desensitization algorithm; the relevant behavior should be covered by tests for logging and desensitization.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.