Medium

Vega vulnerable to Cross-site Scripting via RegExp.prototype[@@replace]

  • Disclosed: 27.03.2025
  • Updated: 11.10.2026 10:22

Impact

Users running Vega/Vega-lite JSON definitions could run unexpected JavaScript code when drawing graphs, unless the library is used with the vega-interpreter.

Workarounds

POC Summary

Calling replace with a RegExp-like pattern calls RegExp.prototype[@@replace], which can then call an attacker-controlled exec function.

POC Details

Consider the function call replace('foo', {__proto__: /h/.constructor.prototype, global: false}). Since pattern has RegExp.prototype[@@replace], pattern.exec('foo') winds up being called.

The resulting malicious call looks like this:

replace(<string argument>, {__proto__: /h/.constructor.prototype, exec: <function>, global: false})

Since functions cannot be returned from this, an attacker that wishes to escalate to XSS must abuse event.view to gain access to eval.

Reproduction steps

{"$schema":"https://vega.github.io/schema/vega/v5.json","signals":[{"name":"a","on":[{"events":"body:mousemove{99999}","update":"replace('alert(1)',{__proto__:/h/.constructor.prototype,exec:event.view.eval,global:false})"}]}]}

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package vega < 5.32.0 5.32.0
npm package vega-functions < 5.17.0 5.17.0

References

CVSS score -
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
Weakness (CWE)
CWE-79, CWE-87
Platform
npm
Package
vega, vega-functions
Disclosed
27.03.2025
Updated
11.10.2026 10:22

Sources and licenses

OSV / GitHub Advisory Database - GHSA-963h-3v39-3pqf - CC BY 4.0

Vulnerability history: vega

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

Total entries
8
First → latest
12.2020 11.2025
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 1
  • Medium 6
  • Low 1

Disclosures per year

  1. 2020: 1
  2. 2021: 0
  3. 2022: 0
  4. 2023: 3
  5. 2024: 0
  6. 2025: 4
  7. 2026: 0
  1. Vega vulnerable to Cross-site Scripting via RegExp.prototype[@@replace] this entry
    Medium CVE-2025-27793 < 5.32.0 5.32.0
  2. Medium ghsa-cp47-r258-q626 >= 5.0.0, < 5.4.1, < 4.5.1 5.4.1, 4.5.1
  3. Medium · 6.1 CVE-2023-26487 < 5.23.0 5.23.0
  4. Low · 8.7 CVE-2020-26296 < 5.17.3 5.17.3

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.