Advisory Database
  • Advisories
  • Dependency Scanning
  1. npm
  2. ›
  3. @babel/runtime
  4. ›
  5. CVE-2025-27789

CVE-2025-27789: Babel has inefficient RegExp complexity in generated code with .replace when transpiling named capturing groups

March 11, 2025 (updated April 16, 2025)

When using Babel 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).

Your generated code is vulnerable if all the following conditions are true:

  • You use Babel to compile regular expression named capturing groups
  • You use the .replace method on a regular expression that contains named capturing groups
  • Your code uses untrusted strings as the second argument of .replace

If you are using @babel/preset-env with the targets option, the transform that injects the vulnerable code is automatically enabled if:

  • you use duplicated named capturing groups, and target any browser older than Chrome/Edge 126, Opera 112, Firefox 129, Safari 17.4, or Node.js 23
  • you use any named capturing groups, and target any browser older than Chrome 64, Opera 71, Edge 79, Firefox 78, Safari 11.1, or Node.js 10

You can verify what transforms @babel/preset-env is using by enabling the debug option.

References

  • github.com/advisories/GHSA-968p-4wvh-cqc8
  • github.com/babel/babel
  • github.com/babel/babel/commit/d5952e80c0faa5ec20e35085531b6e572d31dad4
  • github.com/babel/babel/pull/17173
  • github.com/babel/babel/security/advisories/GHSA-968p-4wvh-cqc8
  • nvd.nist.gov/vuln/detail/CVE-2025-27789

Code Behaviors & Features

Detect and mitigate CVE-2025-27789 with GitLab Dependency Scanning

Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →

Affected versions

All versions before 7.26.10, all versions starting from 8.0.0-alpha.0 before 8.0.0-alpha.17

Fixed versions

  • 7.26.10
  • 8.0.0-alpha.17

Solution

Upgrade to versions 7.26.10, 8.0.0-alpha.17 or above.

Impact 6.2 MEDIUM

CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Learn more about CVSS

Weakness

  • CWE-1333: Inefficient Regular Expression Complexity

Source file

npm/@babel/runtime/CVE-2025-27789.yml

Spotted a mistake? Edit the file on GitLab.

  • Site Repo
  • About GitLab
  • Terms
  • Privacy Statement
  • Contact

Page generated Wed, 14 May 2025 12:14:31 +0000.