CVE-2025-25304: Vega Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-mp7w-mhcv-673j
CWE-79
Published
Advisory Summary

CVE-2025-25304 is a MODERATE cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Vega libraries in the npm ecosystem. The issue involves vega allows cross-site scripting via the vlselectiontuples function. Remediation is available by upgrading affected packages to version 5.26.0, 5.4.2.

CVE-2025-25304 at a Glance

CVE Identifier CVE-2025-25304
GHSA Identifier GHSA-mp7w-mhcv-673j
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Vega
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2025-25304

To remediate this vulnerability, upgrade all affected Vega dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

vega fixed: 5.26.0
npm install vega@5.26.0
vega-selections fixed: 5.4.2
npm install vega-selections@5.4.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls vega

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2025-25304, inspect your project dependencies using npm:

npm ls vega

Analyze the terminal output to locate any version of Vega in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.26.0), your application is affected.

Note: The npm ls vega command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Vega, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The `vlSelectionTuples` function can be used to call JavaScript functions, leading to XSS. ### Details [`vlSelectionTuples`](https://github.com/vega/vega/blob/b45cf431cd6c0d0c0e1567f087f9b3b55bc236fa/packages/vega-selections/src/selectionTuples.js#L14) calls multiple functions that can be controlled by an attacker, including one call with an attacker-controlled argument. Example call: `vlSelectionTuples([{datum:<argument>}], {fields:[{getter:<function>}]})` This can be used to call `Function()` with arbitrary JavaScript and the resulting function can be called with `vlSelectionTuples` or using a type coercion to call `toString` or `valueOf`. ### PoC ``` {"$schema":"https://vega.github.io/schema/vega/v5.json","signals":[{"name":"a","init":"+{valueOf:vlSelectionTuples([{datum:'alert(1)'}],{fields:[{getter:[].at.constructor}]})[0].values[0]}"}]} ```

CVE-2025-25304 Affected Vega Versions

2 component(s)
Fixed Versions:
5.26.05.4.2
Product / Package Ecosystem Affected Versions Fixed Version
vega
npm
< 5.26.0
5.26.0
vega-selections
npm
< 5.4.2
5.4.2

References

Frequently Asked Questions

What is CVE-2025-25304?
CVE-2025-25304 is a security vulnerability in Vega involving Vega allows Cross-site Scripting via the vlSelectionTuples function under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Vega versions are affected?
Affected versions include releases prior to 5.26.0, 5.4.2 across affected packages: vega, vega-selections.
What version fixes CVE-2025-25304?
Upgrading to 5.26.0, 5.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vega affected?
Yes, vega is affected in releases prior to 5.26.0. Upgrade your dependency to 5.26.0 or later.
Is vega-selections affected?
Yes, vega-selections is affected in releases prior to 5.4.2. Upgrade your dependency to 5.4.2 or later.
What CWE is associated with CVE-2025-25304?
CVE-2025-25304 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2025-25304?
Run the dependency tree command: 'npm ls vega'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-mp7w-mhcv-673j",
  "modified" : "2025-02-14T22:17:54Z",
  "published" : "2025-02-14T17:33:58Z",
  "aliases" : [ "CVE-2025-25304" ],
  "summary" : "Vega allows Cross-site Scripting via the vlSelectionTuples function",
  "details" : "### Summary\nThe `vlSelectionTuples` function can be used to call JavaScript functions, leading to XSS.\n\n### Details\n[`vlSelectionTuples`](https://github.com/vega/vega/blob/b45cf431cd6c0d0c0e1567f087f9b3b55bc236fa/packages/vega-selections/src/selectionTuples.js#L14) calls multiple functions that can be controlled by an attacker, including one call with an attacker-controlled argument.\n\nExample call: `vlSelectionTuples([{datum:<argument>}], {fields:[{getter:<function>}]})`\n\nThis can be used to call `Function()` with arbitrary JavaScript and the resulting function can be called with `vlSelectionTuples` or using a type coercion to call `toString` or `valueOf`.\n\n### PoC\n```\n{\"$schema\":\"https://vega.github.io/schema/vega/v5.json\",\"signals\":[{\"name\":\"a\",\"init\":\"+{valueOf:vlSelectionTuples([{datum:'alert(1)'}],{fields:[{getter:[].at.constructor}]})[0].values[0]}\"}]}\n```",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vega"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.26.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vega-selections"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "5.4.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/vega/vega/security/advisories/GHSA-mp7w-mhcv-673j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-25304"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vega/vega/commit/9fb9ea07e27984394e463d286eb73944fa61411e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/vega/vega"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vega/vega/blob/b45cf431cd6c0d0c0e1567f087f9b3b55bc236fa/packages/vega-selections/src/selectionTuples.js#L14"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-02-14T17:33:58Z",
    "nvd_published_at" : "2025-02-14T20:15:36Z"
  }
}