GitHub Advisoryadvisory · npm

GHSA-963h-3v39-3pqf Vega vulnerable to Cross-site Scripting via RegExp.prototype[@@replace]

MEDIUM Published 2025-03-27 Modified 2025-03-27 Official page ↗
Aliases
CVE-2025-27793
Ecosystem
npm
Packages
vega, vega-functions
Severity
Moderate
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
Weaknesses
CWE-79, CWE-87
Reviewed
2025-03-27

Affected packages

• npm vega: < 5.32.0 → fixed in 5.32.0 • npm vega-functions: < 5.17.0 → fixed in 5.17.0

Description

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. 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(, {__proto__: /h/.constructor.prototype, exec: , 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})"}]}]} ```

Related

Alias · CVE (1)

  • CVE-2025-27793 Vega is a visualization grammar, a declarative format for creating, saving, and sharing interactive visualization designs. vulnerability

Weakness · CWE (2)

  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness
  • CWE-87 Improper Neutralization of Alternate XSS Syntax weakness

References