Nunjucks versions 2.5.1 and 2.5.2 are both powerful templating engines designed with inheritance and asynchronous control, drawing inspiration from Jinja2. Aimed at developers seeking a flexible and efficient way to generate dynamic content, Nunjucks provides a robust toolset for building web applications and other projects.
Both versions share identical core dependencies, including "asap" for asynchronous operations, "chokidar" for file system monitoring, and "yargs" for command-line argument parsing. Similarly, the development dependencies remain the same, featuring tools for testing ("expect.js", "mocha", "supertest"), code quality ("jshint", "istanbul"), and building assets ("uglify-js", "webpack", "node-libs-browser"). This indicates a consistent focus on code quality and development workflow across both releases.
The primary distinction lies in the release date. Version 2.5.2 was published on September 14, 2016, a day after version 2.5.1, which was released on September 13, 2016. The minimal version difference suggests that version 2.5.2 is likely a patch release addressing minor bugs or incorporating small improvements identified shortly after the initial 2.5.1 release. Developers already using Nunjucks can transition easily, confident that their existing templates and configurations will likely remain compatible. While the specifics require consulting the changelog (likely available from the Nunjucks Github repository), this quick iteration emphasizes a commitment to stability and addressing any urgent issues promptly.
All the vulnerabilities related to the version 2.5.2 of the package
Nunjucks autoescape bypass leads to cross site scripting
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.
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)//
The issue was patched in version 3.2.4.
Regular Expression Denial of Service (ReDoS) in micromatch
The NPM package micromatch
prior to version 4.0.8 is vulnerable to Regular Expression Denial of Service (ReDoS). The vulnerability occurs in micromatch.braces()
in index.js
because the pattern .*
will greedily match anything. By passing a malicious payload, the pattern matching will keep backtracking to the input while it doesn't find the closing bracket. As the input size increases, the consumption time will also increase until it causes the application to hang or slow down. There was a merged fix but further testing shows the issue persisted prior to https://github.com/micromatch/micromatch/pull/266. This issue should be mitigated by using a safe pattern that won't start backtracking the regular expression due to greedy matching.
Regular Expression Denial of Service (ReDoS) in braces
A vulnerability was found in Braces versions prior to 2.3.1. Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) attacks.
Regular Expression Denial of Service in braces
Versions of braces
prior to 2.3.1 are vulnerable to Regular Expression Denial of Service (ReDoS). Untrusted input may cause catastrophic backtracking while matching regular expressions. This can cause the application to be unresponsive leading to Denial of Service.
Upgrade to version 2.3.1 or higher.
Uncontrolled resource consumption in braces
The NPM package braces
fails to limit the number of characters it can handle, which could lead to Memory Exhaustion. In lib/parse.js,
if a malicious user sends "imbalanced braces" as input, the parsing will enter a loop, which will cause the program to start allocating heap memory without freeing it at any moment of the loop. Eventually, the JavaScript heap limit is reached, and the program will crash.