CVE-2023-2142: Nunjucks autoescape bypass leads to cross site scripting
6.1
CVSS Score
3.1
Basic Information
CVE ID
GHSA ID
EPSS Score
0.21092%
CWE
Published
4/20/2023
Updated
11/26/2024
KEV Status
No
Technology
JavaScript
Technical Details
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| nunjucks | npm | < 3.2.4 | 3.2.4 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability stems from incomplete HTML escaping in Nunjucks' autoescape mechanism. The commit diff shows:
- Backslash was added to escapeMap with HTML entity encoding
- escapeRegex was modified to include backslashes
- Tests were added for backslash escaping
This indicates the core vulnerability was in the escaping logic handled by lib.js's escape mechanisms. The autoescape feature relied on these patterns to neutralize special characters, and the absence of backslash handling allowed XSS bypass when combined with multiple user-controlled parameters in template interpolation.