Vulnerability · Published Mar 11, 2025 · Assigned by GitHub_M
CVE-2025-27789Inefficient RexExp complexity in generated code with .replace when transpiling named capturing groups
Medium 6.2
In plain English
A medium-severity regular-expression denial of service in babel from babel. Proof-of-concept exploit code is public. The chance it is exploited in the next 30 days is estimated at 0.6% (higher than 47% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
Babel is a compiler for writing next generation JavaScript. When using versions of Babel prior to 7.26.10 and 8.0.0-alpha.17 to compile regular expression named capturing groups, Babel will generate a polyfill for the `.replace` method that has quadratic complexity on some specific replacement pattern strings (i.e. the second argument passed to `.replace`). Generated code is vulnerable if all the following conditions are true: Using Babel to compile regular expression named capturing groups, using the `.replace` method on a regular expression that contains named capturing groups, and the code using untrusted strings as the second argument of `.replace`. This problem has been fixed in `@babel/helpers` and `@babel/runtime` 7.26.10 and 8.0.0-alpha.17. It's likely that individual users do not directly depend on `@babel/helpers`, and instead depend on `@babel/core` (which itself depends on `@babel/helpers`). Upgrading to `@babel/core` 7.26.10 is not required, but it guarantees use of a new enough `@babel/helpers` version. Note that just updating Babel dependencies is not enough; one will also need to re-compile the code. No known workarounds are available.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu:22.04:LTS | node-babel7 | no fix listed | UBUNTU-CVE-2025-27789 |
| Ubuntu:24.04:LTS | node-babel7 | no fix listed | UBUNTU-CVE-2025-27789 |
| Ubuntu:25.10 | node-babel7 | no fix listed | UBUNTU-CVE-2025-27789 |
| Ubuntu:26.04:LTS | node-babel7 | no fix listed | UBUNTU-CVE-2025-27789 |
| Ubuntu:26.10 | node-babel7 | no fix listed | UBUNTU-CVE-2025-27789 |
| npm | @babel/helpers | 7.26.10 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/helpers | 8.0.0-alpha.17 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/runtime | 8.0.0-alpha.17 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/runtime | 7.26.10 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/runtime-corejs2 | 8.0.0-alpha.17 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/runtime-corejs2 | 7.26.10 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/runtime-corejs3 | 8.0.0-alpha.17 | GHSA-968p-4wvh-cqc8 |
| npm | @babel/runtime-corejs3 | 7.26.10 | GHSA-968p-4wvh-cqc8 |
Affected products (as reported)
Weakness: CWE-1333 · Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
References
- https://github.com/babel/babel/security/advisories/GHSA-968p-4wvh-cqc8 x_refsource_CONFIRM
- https://github.com/babel/babel/pull/17173 x_refsource_MISC