← Back to PRs

#16936: Fix Feishu mention stripping vulnerable to regex injection

by Clawborn open 2026-02-15 08:05 View on GitHub →
channel: feishu stale size: S trusted-contributor
`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