CVE-2026-42345: Broken Json String Escaping Lookbehind Replace

Insecure manual JSON string escaping: using .replace(/(?<!\\)"/g, '\\"') to sanitize user-controlled values for JSON string interpolation is bypassable. The negative lookbehind treats a user-supplied backslash before a double-quote as an escape prefix, so that quote is left unescaped in the output. Because the backslash itself is never encoded to '\\', the J

Provally CuratedPublic repositoryHighHigh confidenceVerifiedApache-2.0JS
greprules fetch cve-2026-42345-broken-json-string-escaping-lookbehind-replace --engine opengrep

Description

Insecure manual JSON string escaping: using .replace(/(?<!\\)"/g, '\\"') to sanitize user-controlled values for JSON string interpolation is bypassable. The negative lookbehind treats a user-supplied backslash before a double-quote as an escape prefix, so that quote is left unescaped in the output. Because the backslash itself is never encoded to '\\', the J