Babel-jest is a crucial Jest plugin that leverages Babel for transforming JavaScript code, enabling developers to seamlessly test modern JavaScript features and syntax within their Jest testing environment. Comparing version 23.0.0 with its predecessor, 22.4.4, several key distinctions emerge that are important for developers to consider.
Primarily, the core dependency, babel-preset-jest, has been updated to match the major version of babel-jest, moving from ^22.4.4 to ^23.0.0. This ensures compatibility and access to the latest features and bug fixes within the preset specifically designed for Jest. Furthermore, babel-plugin-istanbul, responsible for code coverage instrumentation, sees a minor update from version 4.1.5 to 4.1.6, likely bringing improvements in coverage reporting accuracy or performance. While the peer dependency on babel-core remains consistent (^6.0.0 || ^7.0.0-0), indicating continued support for both Babel 6 and Babel 7, developers should verify compatibility with their specific Babel configurations.
The distribution details also show some changes. Version 23.0.0 has a larger unpacked size (6773 bytes) and a higher file count (6) compared to version 22.4.4 (6541 bytes and 3 files), potentially indicating the introduction of new features, refactoring, or additional test files. Lastly, version 23.0.0 was released on May 24, 2018, subsequent to version 22.4.4 released on May 18, 2018. Developers should prioritize using the latest version for the most up-to-date features, performance enhancements, and bug fixes, while carefully reviewing release notes for any breaking changes that may impact their testing setup.
All the vulnerabilities related to the version 23.0.0 of the package
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.
Babel vulnerable to arbitrary code execution when compiling specifically crafted malicious code
Using Babel to compile code that was specifically crafted by an attacker can lead to arbitrary code execution during compilation, when using plugins that rely on the path.evaluate()
or path.evaluateTruthy()
internal Babel methods.
Known affected plugins are:
@babel/plugin-transform-runtime
@babel/preset-env
when using its useBuiltIns
option@babel/helper-define-polyfill-provider
, such as babel-plugin-polyfill-corejs3
, babel-plugin-polyfill-corejs2
, babel-plugin-polyfill-es-shims
, babel-plugin-polyfill-regenerator
No other plugins under the @babel/
namespace are impacted, but third-party plugins might be.
Users that only compile trusted code are not impacted.
The vulnerability has been fixed in @babel/traverse@7.23.2
.
Babel 6 does not receive security fixes anymore (see Babel's security policy), hence there is no patch planned for babel-traverse@6
.
@babel/traverse
to v7.23.2 or higher. You can do this by deleting it from your package manager's lockfile and re-installing the dependencies. @babel/core
>=7.23.2 will automatically pull in a non-vulnerable version.@babel/traverse
and are using one of the affected packages mentioned above, upgrade them to their latest version to avoid triggering the vulnerable code path in affected @babel/traverse
versions:
@babel/plugin-transform-runtime
v7.23.2@babel/preset-env
v7.23.2@babel/helper-define-polyfill-provider
v0.4.3babel-plugin-polyfill-corejs2
v0.4.6babel-plugin-polyfill-corejs3
v0.8.5babel-plugin-polyfill-es-shims
v0.10.0babel-plugin-polyfill-regenerator
v0.5.3