CVE-2025-59840 Vega Cross-Site Scripting (XSS) via expressions abusing toString calls in environments using the VEGA_DEBUG global variable

High 8.1 Published Updated

Attackers can execute arbitrary JavaScript in Vega applications if the library and View instances are attached to the global window object.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2025-59840?

CVE-2025-59840 is a high-severity cross-site scripting vulnerability in vega, published on 13 Nov 2025. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

Vega is a visualization grammar, a declarative format for creating, saving, and sharing interactive visualization designs. In Vega prior to version 6.2.0, applications meeting 2 conditions are at risk of arbitrary JavaScript code execution, even if "safe mode" expressionInterpreter is used. They are vulnerable if they use `vega` in an application that attaches `vega` library and a `vega.View` instance similar to the Vega Editor to the global `window` and if they allow user-defined Vega `JSON` definitions (vs JSON that was is only provided through source code). Patches are available in the following Vega applications. If using the latest Vega line (6.x), upgrade to `vega` `6.2.0` / `vega-expression` `6.1.0` / `vega-interpreter` `2.2.1` (if using AST evaluator mode). If using Vega in a non-ESM environment, upgrade to `vega-expression` `5.2.1` / `1.2.1` (if using AST evaluator mode). Some workarounds are available. Do not attach `vega` View instances to global variables, and do not attach `vega` to the global window. These practices of attaching the vega library and View instances may be convenient for debugging, but should not be used in production or in any situation where vega/vega-lite definitions could be provided by untrusted parties.

Weakness: CWE-79

Which versions are affected by CVE-2025-59840?

10 open source packages ship an affected version, including vega-expression, vega and vega-interpreter.

PackageAffectedFixed in
vega-expression npmAll versions5.2.1
vega-expression npmAll versions5.2.1
vega-expression npmFrom 6.0.06.1.0
vega-expression npmFrom 6.0.06.1.0
vega npmAll versions6.2.0
vega npmAll versions6.2.0
4 more packages
vega-interpreter npmAll versions1.2.1
vega-interpreter npmAll versions1.2.1
vega-interpreter npmFrom 2.0.02.2.1
vega-interpreter npmFrom 2.0.02.2.1

How do I fix CVE-2025-59840?

Upgrade vega-expression to a fixed version for your release line: 5.2.1 or 6.1.0.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2025-59840 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2025-59840 exists.

Sources

Also known as DEBIAN-CVE-2025-59840, GHSA-7f2v-3qq3-vvjf, UBUNTU-CVE-2025-59840.

Is CVE-2025-59840 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free