CVE-2023-2142
NoneCVSS
—
EPSS
0.4%
Published
Apr 20, 2023
CISA due date
—
Cloudanix analysis
A flaw in a popular web template tool could let attackers slip harmful code into pages viewed by users, potentially stealing information or taking over sessions if the tool is not updated.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Low
- Impact
- Data Exposure
- Component
- Library
- Class
- XSS
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
The flaw permits unsanitized user input to be rendered directly into HTML output by the nunjucks template engine, bypassing built-in escaping and allowing arbitrary script execution in the context of the victim's browser.
Why it matters to the business
Organizations using older nunjucks versions face risk of client-side attacks that could steal session tokens, redirect users, or deface web interfaces, though the vulnerability's age and low exploitation probability reduce immediate operational disruption.
How an attack unfolds
An attacker supplies crafted input containing HTML and script tags to an application that passes the data into nunjucks templates without proper escaping; when the page renders for another user, the injected code executes in that user's browser session.
How to fix it
Upgrade mozilla/nunjucks to the version containing commit 86a77f49da4779d55414d8337e1a4d7ec7582da5 or later; enable autoescaping on all templates and review custom filters for unsafe HTML output.
How to confirm the fix worked
Confirm nunjucks version is at or beyond the fixed commit, run automated XSS scanners against affected templates, and manually test input fields with known payload vectors to verify escaping behavior.
Typical attack path
- Identify application endpoints that accept input later rendered by nunjucks templates
- Craft payload containing script or event-handler tags that bypasses existing sanitization
- Submit payload via form, query parameter, or API request
- Wait for or lure a victim user to view the rendered page
- Execute arbitrary JavaScript in the victim's browser context
How to detect it
Review web application logs and template rendering traces for unexpected script tags or event handlers in rendered output; examine access logs for repeated requests containing common XSS payload patterns to nunjucks-dependent endpoints.
What your security team should do
- Prioritize upgrade of nunjucks in all applications to the fixed commit
- Audit template usage to ensure autoescape is enabled by default
- Add input validation and output encoding layers as defense-in-depth
- Monitor dependency scanners for any remaining nunjucks instances below the fixed version
The record
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in nunjucks.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| npm | nunjucks | 0 | 3.2.4 |
| Debian:12 | node-nunjucks | 0 | No fix |
| Debian:13 | node-nunjucks | 0 | No fix |
| Ubuntu:24.04:LTS | node-nunjucks | 0 | No fix |
| Ubuntu:24.10 | node-nunjucks | 0 | No fix |
| Ubuntu:25.04 | node-nunjucks | 0 | No fix |
| Ubuntu:25.10 | node-nunjucks | 0 | No fix |
Related vulnerabilities
- CVE-2026-38739 ezsystems/ezpublish-legacy has a SQL injection in dfscleanup CWE-1035
- CVE-2026-47121 Sparkle: Binary delta apply intermediate-symlink traversal in malicious .delta CWE-1035
- CVE-2026-47255 AgenticMail API/storage and outbound relay hardening fixes CWE-1035
- CVE-2026-47122 Sparkle's AppInstaller post-stage-1 XPC listener accepts unvalidated connections… CWE-1035
- CVE-2026-47695 CC-Tweaked has an SSRF Protection Bypass with NAT64 CWE-1035
- GHSA-7cwm-fpfh-rrch Ironic Standalone Operator's prometheus metrics exporter bound to all interfaces CWE-1035
- GHSA-hfc8-w5f4-3x6m Ironic Standalone Operator's controller modifies user-owned resources without consent CWE-1035
- GHSA-92vj-hp7m-gwcj Nerdbank.MessagePack has Inefficient CPU Computation CWE-1035