Skip to content

Nunjucks autoescape bypass leads to cross site scripting

Moderate severity GitHub Reviewed Published Apr 19, 2023 in mozilla/nunjucks • Updated Apr 20, 2023

Package

npm nunjucks (npm)

Affected versions

< 3.2.4

Patched versions

3.2.4

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

References

@fkiriakos07 fkiriakos07 published to mozilla/nunjucks Apr 19, 2023
Published to the GitHub Advisory Database Apr 20, 2023
Reviewed Apr 20, 2023
Last updated Apr 20, 2023

Severity

Moderate

Weaknesses

CVE ID

CVE-2023-2142

GHSA ID

GHSA-x77j-w7wf-fjmw

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.