CVE-2025-27789 Inefficient RexExp complexity in generated code with .replace when transpiling named capturing groups
Babel generates inefficient code for named capturing groups, allowing attackers to cause denial of service via quadratic complexity in replace operations.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Local or same network only
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2025-27789?
CVE-2025-27789 is a medium-severity denial of service vulnerability in babel, published on 11 Mar 2025. It can only be exploited from the same machine or local network, with no action from the victim.
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.
Weakness: CWE-1333
Which versions are affected by CVE-2025-27789?
16 open source packages ship an affected version, including @babel/helpers, @babel/runtime and @babel/runtime-corejs2.
| Package | Affected | Fixed in |
|---|---|---|
@babel/helpers npm | All versions | 7.26.10 |
@babel/helpers npm | All versions | 7.26.10 |
@babel/helpers npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/helpers npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/runtime npm | All versions | 7.26.10 |
@babel/runtime npm | All versions | 7.26.10 |
10 more packages
@babel/runtime npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/runtime npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/runtime-corejs2 npm | All versions | 7.26.10 |
@babel/runtime-corejs2 npm | All versions | 7.26.10 |
@babel/runtime-corejs2 npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/runtime-corejs2 npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/runtime-corejs3 npm | All versions | 7.26.10 |
@babel/runtime-corejs3 npm | All versions | 7.26.10 |
@babel/runtime-corejs3 npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
@babel/runtime-corejs3 npm | From 8.0.0-alpha.0 | 8.0.0-alpha.17 |
How do I fix CVE-2025-27789?
Upgrade @babel/helpers to a fixed version for your release line: 7.26.10 or 8.0.0-alpha.17.
Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.
Is CVE-2025-27789 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-27789 exists.
Sources
Also known as CLEANSTART-2026-MC82995, CLSA-2026-1775781182, CLSA-2026-1775781183, CLSA-2026-1775781185, CLSA-2026-1775781186, CLSA-2026-1775781187 and 141 more.