#16936: Fix Feishu mention stripping vulnerable to regex injection
channel: feishu
stale
size: S
trusted-contributor
Cluster:
Feishu Integration Enhancements
`stripBotMention` in the Feishu extension constructs a `RegExp` from `mention.name` and `mention.key` without escaping special regex characters. If a Feishu user's display name contains `+`, `.`, `(`, `]`, or similar, the regex either throws a SyntaxError at runtime or silently matches unintended patterns.
Note that `extensions/feishu/src/mention.ts:70` already does this correctly — the escaping pattern was just missed in `bot.ts`.
**Fix:** Escape both `mention.name` and `mention.key` before interpolating into `RegExp`.
**Tests:** 6 test cases including regex special chars in names/keys and edge cases.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed a regex injection vulnerability in `stripBotMention` function where Feishu user display names or keys containing regex special characters (`+`, `.`, `(`, `]`, etc.) were used directly in `RegExp` construction. This could cause runtime crashes (SyntaxError) or unintended pattern matching.
- Escapes `mention.name` and `mention.key` using standard regex escaping pattern before constructing RegExp
- Follows the existing escaping pattern already used in `mention.ts:70`
- Adds comprehensive test coverage with 6 test cases covering normal mentions, regex special characters in names and keys, and edge cases
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with no risk
- The fix addresses a clear security vulnerability with the standard regex escaping pattern, includes comprehensive test coverage that all pass, and follows existing patterns in the codebase. The change is minimal, well-tested, and correctly implements the fix.
- No files require special attention
<sub>Last reviewed commit: e160319</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#16337: feat(feishu): sync community plugin updates from clawdbot-feishu v0...
by graydawnc · 2026-02-14
73.6%
#20973: Fix: Feishu duplicate plugin ID, Docker pairing docs, broken formal...
by neipor · 2026-02-19
73.3%
#11774: fix: add guards for undefined mentionRegexes arrays
by ikvyk · 2026-02-08
73.1%
#17244: fix: strip TTS tags from agent replies before delivery (#14652)
by robbyczgw-cla · 2026-02-15
72.1%
#12755: feat(feishu): render post rich text as markdown
by WilsonLiu95 · 2026-02-09
71.9%
#19254: fix(feishu): honor wildcard group config for reply policy
by WaynePika · 2026-02-17
71.9%
#13761: fix(feishu): silently degrade when contact permission is missing
by echoVic · 2026-02-11
71.3%
#17256: fix: allow text regex fallback when bot JID not in mentionedJids
by DarlingtonDeveloper · 2026-02-15
71.3%
#13211: feat(feishu): skip reply-to in DM conversations
by Vincentwei1021 · 2026-02-10
71.2%
#22675: feishu: move message dedup to just before dispatch
by zijiegeng · 2026-02-21
71.0%