mozilla/nunjucks · Security
Nunjucks autoescape bypass leads to cross site scripting
- GHSA ID
- GHSA-x77j-w7wf-fjmw
- CVE ID
- CVE-2023-2142
- Severity
- medium
- Published
- Updated
- CVSS
- 6.1 · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- CVSS v3
- 6.1 · CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- CVSS v4
- 5.3 · CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
Description
Impact
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.
Example
If the user-controlled parameters were used in the views similar to the following:
<script>
let testObject = { lang: '{{ lang }}', place: '{{ place }}' };
</script>
It is possible to inject XSS payload using the below parameters:
https://<application-url>/?lang=jp\&place=};alert(document.domain)//
Patches
The issue was patched in version 3.2.4.
References
CWEs
- CWE-79 · Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
References
- https://github.com/mozilla/nunjucks/security/advisories/GHSA-x77j-w7wf-fjmw ↗
- https://github.com/mozilla/nunjucks/pull/1437 ↗
- https://github.com/mozilla/nunjucks/commit/ec16d210e7e13f862eccdb0bc9af9f60ff6749d6 ↗
- https://bugzilla.mozilla.org/show_bug.cgi?id=1825980 ↗
- https://github.com/mozilla/nunjucks/releases/tag/v3.2.4 ↗
- https://nvd.nist.gov/vuln/detail/CVE-2023-2142 ↗
- https://github.com/advisories/GHSA-x77j-w7wf-fjmw ↗