Moderate severityNVD Advisory· Published Mar 18, 2026· Updated Mar 18, 2026
OpenClaw < 2026.2.19 - ReDoS and Regex Injection via Unescaped Feishu Mention Metadata
CVE-2026-22178
Description
OpenClaw versions prior to 2026.2.19 construct RegExp objects directly from unescaped Feishu mention metadata in the stripBotMention function, allowing regex injection and denial of service. Attackers can craft nested-quantifier patterns or metacharacters in mention metadata to trigger catastrophic backtracking, block message processing, or remove unintended content before model processing.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
openclawnpm | < 2026.2.19 | 2026.2.19 |
Affected products
1Patches
2742684891375test(feishu): add mention regex injection regressions
2 files changed · +23 −1
CHANGELOG.md+1 −0 modified@@ -36,6 +36,7 @@ Docs: https://docs.openclaw.ai - Scripts: update clawdock helper command support to include `docker-compose.extra.yml` where available. (#17094) Thanks @zerone0x. - Security/iMessage: harden remote attachment SSH/SCP handling by requiring strict host-key verification, validating `channels.imessage.remoteHost` as `host`/`user@host`, and rejecting unsafe host tokens from config or auto-detection. Thanks @allsmog for reporting. - Security/Feishu: prevent path traversal in Feishu inbound media temp-file writes by replacing key-derived temp filenames with UUID-based names. Thanks @allsmog for reporting. +- Security/Feishu: escape mention regex metacharacters in `stripBotMention` so crafted mention metadata cannot trigger regex injection or ReDoS during inbound message parsing. (#20916) Thanks @allsmog for reporting. - LINE/Security: harden inbound media temp-file naming by using UUID-based temp paths for downloaded media instead of external message IDs. (#20792) Thanks @mbelinky. - Security/Refactor: centralize hardened temp-file path generation for Feishu and LINE media downloads via shared `buildRandomTempFilePath` helper to reduce drift risk. (#20810) Thanks @mbelinky. - Security/Media: harden local media ingestion against TOCTOU/symlink swap attacks by pinning reads to a single file descriptor with symlink rejection and inode/device verification in `saveMediaSource`. Thanks @dorjoos for reporting.
extensions/feishu/src/bot.checkBotMentioned.test.ts+22 −1 modified@@ -5,6 +5,7 @@ import { parseFeishuMessageEvent } from "./bot.js"; function makeEvent( chatType: "p2p" | "group", mentions?: Array<{ key: string; name: string; id: { open_id?: string } }>, + text = "hello", ) { return { sender: { @@ -15,7 +16,7 @@ function makeEvent( chat_id: "oc_chat1", chat_type: chatType, message_type: "text", - content: JSON.stringify({ text: "hello" }), + content: JSON.stringify({ text }), mentions, }, }; @@ -62,6 +63,26 @@ describe("parseFeishuMessageEvent – mentionedBot", () => { expect(ctx.mentionedBot).toBe(false); }); + it("treats mention.name regex metacharacters as literals when stripping", () => { + const event = makeEvent( + "group", + [{ key: "@_bot_1", name: ".*", id: { open_id: BOT_OPEN_ID } }], + "@NotBot hello", + ); + const ctx = parseFeishuMessageEvent(event as any, BOT_OPEN_ID); + expect(ctx.content).toBe("@NotBot hello"); + }); + + it("treats mention.key regex metacharacters as literals when stripping", () => { + const event = makeEvent( + "group", + [{ key: ".*", name: "Bot", id: { open_id: BOT_OPEN_ID } }], + "hello world", + ); + const ctx = parseFeishuMessageEvent(event as any, BOT_OPEN_ID); + expect(ctx.content).toBe("hello world"); + }); + it("returns mentionedBot=true for post message with at (no top-level mentions)", () => { const BOT_OPEN_ID = "ou_bot_123"; const postContent = JSON.stringify({
7e67ab75cc2ffix(feishu): escape regex metacharacters in stripBotMention
1 file changed · +6 −2
extensions/feishu/src/bot.ts+6 −2 modified@@ -199,15 +199,19 @@ function checkBotMentioned(event: FeishuMessageEvent, botOpenId?: string): boole return false; } +function escapeRegExp(s: string): string { + return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + function stripBotMention( text: string, mentions?: FeishuMessageEvent["message"]["mentions"], ): string { if (!mentions || mentions.length === 0) return text; let result = text; for (const mention of mentions) { - result = result.replace(new RegExp(`@${mention.name}\\s*`, "g"), "").trim(); - result = result.replace(new RegExp(mention.key, "g"), "").trim(); + result = result.replace(new RegExp(`@${escapeRegExp(mention.name)}\\s*`, "g"), "").trim(); + result = result.replace(new RegExp(escapeRegExp(mention.key), "g"), "").trim(); } return result; }
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/openclaw/openclaw/commit/74268489137510b6f6349919d1e197b17290d92cghsapatchWEB
- github.com/openclaw/openclaw/commit/7e67ab75cc2f0e93569d12fecd1411c2961fcc8cghsapatchWEB
- github.com/advisories/GHSA-c6hr-w26q-c636ghsaADVISORY
- github.com/openclaw/openclaw/security/advisories/GHSA-c6hr-w26q-c636ghsathird-party-advisoryWEB
- nvd.nist.gov/vuln/detail/CVE-2026-22178ghsaADVISORY
- www.vulncheck.com/advisories/openclaw-redos-and-regex-injection-via-unescaped-feishu-mention-metadataghsathird-party-advisoryWEB
News mentions
0No linked articles in our index yet.