CVE-2023-2142 Nunjucks autoescape bypass leads to cross site scripting

Medium 6.1 Published Updated

Attackers can bypass autoescape to inject cross-site scripting payloads via backslash characters in user-controlled parameters.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2023-2142?

CVE-2023-2142 is a medium-severity cross-site scripting vulnerability in Mozilla Nunjucks, published on 26 Nov 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

In Nunjucks versions prior to version 3.2.4, it was possible to bypass the restrictions which are provided by the autoescape functionality. If there are two user-controlled parameters on the same line used in the views, it was possible to inject cross site scripting payloads using the backslash \ character.

Weakness: CWE-79

Which versions are affected by CVE-2023-2142?

2 open source packages ship an affected version, including nunjucks. It affects 1 product.

PackageAffectedFixed in
nunjucks npmAll versions3.2.4
nunjucks npmAll versions3.2.4

Products include Mozilla Nunjucks.

How do I fix CVE-2023-2142?

Upgrade nunjucks to 3.2.4 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2023-2142 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-2142 exists.

Sources

Also known as DEBIAN-CVE-2023-2142, GHSA-x77j-w7wf-fjmw, UBUNTU-CVE-2023-2142.

Is CVE-2023-2142 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free