# 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.

- **Severity:** Medium 6.2 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 11 Mar 2025
- **Updated:** 11 Mar 2025
- **Also known as:** CLEANSTART-2026-MC82995, CLSA-2026-1775781182, CLSA-2026-1775781183, CLSA-2026-1775781185, CLSA-2026-1775781186, CLSA-2026-1775781187, CLSA-2026-1791249618, CLSA-2026-1791293360, CLSA-2026-1792160950, CLSA-2026-1792160974, CLSA-2026-1792161414, CLSA-2026-1792161415, CLSA-2026-1792161416, CLSA-2026-1792161417, CLSA-2026-1792161612, CLSA-2026-1792161613, CLSA-2026-1792161614, CLSA-2026-1792161727, CLSA-2026-1792161728, CLSA-2026-1792161729, CLSA-2026-1792161835, CLSA-2026-1792161881, CLSA-2026-1792161882, CLSA-2026-1792161883, CLSA-2026-1792161884, CLSA-2026-1792161946, CLSA-2026-1792161948, CLSA-2026-1792161949, CLSA-2026-1792161950, CLSA-2026-1792161979, CLSA-2026-1792161980, CLSA-2026-1792161981, CLSA-2026-1792161982, CLSA-2026-1792162016, CLSA-2026-1792162017, CLSA-2026-1792162018, CLSA-2026-1792162019, CLSA-2026-1792162041, CLSA-2026-1792162042, CLSA-2026-1792162043, CLSA-2026-1792162044, CLSA-2026-1792162065, CLSA-2026-1792162066, CLSA-2026-1792162067, CLSA-2026-1792162068, CLSA-2026-1792162084, CLSA-2026-1792162085, CLSA-2026-1792162086, CLSA-2026-1792162087, CLSA-2026-1792162108, CLSA-2026-1792162109, CLSA-2026-1792162110, CLSA-2026-1792162111, CLSA-2026-1792162132, CLSA-2026-1792162133, CLSA-2026-1792162134, CLSA-2026-1792162135, CLSA-2026-1792162154, CLSA-2026-1792162155, CLSA-2026-1792162173, CLSA-2026-1792162175, CLSA-2026-1792162176, CLSA-2026-1792162177, CLSA-2026-1792162205, CLSA-2026-1792162206, CLSA-2026-1792163434, CLSA-2026-1792163435, CLSA-2026-1792163436, CLSA-2026-1792190623, CLSA-2026-1792194436, CLSA-2026-1792194441, CLSA-2026-1792278648, CLSA-2026-1792421272, CLSA-2026-1792421280, CLSA-2026-1792421281, CLSA-2026-1792423764, CLSA-2026-1792423771, CLSA-2026-1792423773, CLSA-2026-1792495999, CLSA-2026-1792536111, CLSA-2026-1792536116, CLSA-2026-1792760087, CLSA-2026-1792760088, CLSA-2026-1792760089, CLSA-2026-1792760113, CLSA-2026-1792760117, CLSA-2026-1792760139, CLSA-2026-1792760140, CLSA-2026-1792760142, CLSA-2026-1792868953, CLSA-2026-1792868955, CLSA-2026-1792868956, CLSA-2026-1792868965, CLSA-2026-1792868967, CLSA-2026-1792868968, CLSA-2026-1792868969, CLSA-2026-1792868973, CLSA-2026-1792868975, CLSA-2026-1793141354, CLSA-2026-1793141368, CLSA-2026-1793141403, CLSA-2026-1793141508, CLSA-2026-1793141509, CLSA-2026-1793141517, CLSA-2026-1793141518, CLSA-2026-1793154867, CLSA-2026-1793154885, CLSA-2026-1793154946, CLSA-2026-1793154948, CLSA-2026-1793154950, CLSA-2026-1793159553, CLSA-2026-1793159582, CLSA-2026-1793159583, CLSA-2026-1793159584, CLSA-2026-1793159585, CLSA-2026-1793162324, CLSA-2026-1793162325, CLSA-2026-1793162331, CLSA-2026-1793162372, CLSA-2026-1793162373, CLSA-2026-1793162374, CLSA-2026-1793165566, CLSA-2026-1793165590, CLSA-2026-1793173347, CLSA-2026-1793173351, CLSA-2026-1793173358, CLSA-2026-1793173359, CLSA-2026-1793173362, CLSA-2026-1793173363, CLSA-2026-1793173367, CLSA-2026-1793173401, CLSA-2026-1793173415, CLSA-2026-1793173416, CLSA-2026-1793173418, CLSA-2026-1793173419, CLSA-2026-1793173443, ECHO-4c2b-28e6-6831, GHSA-968p-4wvh-cqc8, MINI-3m2g-rh76-6767, MINI-6755-cp2p-wpvg, MINI-7422-43r6-x5qf, MINI-9hc9-2fp5-grrq, MINI-fvww-22j3-fxmp, MINI-jq3v-f793-h4xr, MINI-vqxf-g86f-w53g, ROOT-APP-NPM-CVE-2025-27789, UBUNTU-CVE-2025-27789

## 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 (Inefficient Regular Expression Complexity)

## 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 | Ecosystem | 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 |
| `@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.

## Is CVE-2025-27789 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-27789 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-27789 and fix it if it is affected.

What it is: 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.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-27789 exists.

Affected packages and fixed versions:
- @babel/helpers (npm): affected all versions; fixed in 7.26.10
- @babel/helpers (npm): affected all versions; fixed in 7.26.10
- @babel/helpers (npm): affected from 8.0.0-alpha.0; fixed in 8.0.0-alpha.17
- @babel/helpers (npm): affected from 8.0.0-alpha.0; fixed in 8.0.0-alpha.17
- @babel/runtime (npm): affected all versions; fixed in 7.26.10
- @babel/runtime (npm): affected all versions; fixed in 7.26.10
- @babel/runtime (npm): affected from 8.0.0-alpha.0; fixed in 8.0.0-alpha.17
- @babel/runtime (npm): affected from 8.0.0-alpha.0; fixed in 8.0.0-alpha.17
- @babel/runtime-corejs2 (npm): affected all versions; fixed in 7.26.10
- @babel/runtime-corejs2 (npm): affected all versions; fixed in 7.26.10
- @babel/runtime-corejs2 (npm): affected from 8.0.0-alpha.0; fixed in 8.0.0-alpha.17
- @babel/runtime-corejs2 (npm): affected from 8.0.0-alpha.0; fixed in 8.0.0-alpha.17

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2025-27789/ (Markdown: https://insights.sbomify.com/CVE-2025-27789/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2025-27789
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2025-27789
- OSV: https://osv.dev/vulnerability/CVE-2025-27789

---
From sbomify Insights: https://insights.sbomify.com/CVE-2025-27789/
Summaries are generated and may contain mistakes; the official description above is the record.
