apache / apache/shenyu

[BUG] KeyWordMatch builds regex from unescaped user keywords — PatternSyntaxException

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

Description

- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-desensitize-api/.../matcher/KeyWordMatch.java:36-46`
- description: The constructor iterates over the keyword set and appends each keyword directly into a regex `StringBuilder` without escaping: `sb.append(tempKeyWord)`. If any keyword contains regex metacharacters (`(`, `[`, `.`, `*`, `\`, `+`, `?`, `{`, `|`), `Pattern.compile` throws `PatternSyntaxException`. This propagates from `AbstractLoggingPlugin.doExecute()` line 119.
- impact: A single misconfigured keyword containing regex metacharacters breaks all request handling for every request matching that rule.
- suggested_fix: Use `Pattern.quote(tempKeyWord)` to escape each keyword before appending.
- confidence: High
- related_existing: none

---
_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 in shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-desensitize-api/.../matcher/KeyWordMatch.java:36-46 and inspect how the constructor builds its regex, then trace the failure through AbstractLoggingPlugin.doExecute() at line 119. Verify that keywords containing regex metacharacters are treated literally and no PatternSyntaxException breaks matching.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.