# CVE-2025-59840: Vega Cross-Site Scripting via toString in VEGA_DEBUG

Source: https://junglewise.ai/threats/cve-2025-59840-vega-cross-site-scripting-via-tostring-in-vega-debug  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2025-11-13. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2025-59840 · Severity: high · CVSS 8.1 · Published 2025-11-13

Vega is a JavaScript visualization library used to build interactive data visualizations. When a Vega application exposes Vega objects to the global window scope (a common debugging practice), attackers can craft malicious visualization specifications that execute arbitrary JavaScript code in the victim's browser. An attacker can exploit this by tricking a user into opening a malicious Vega visualization file, leading to theft of authentication tokens, data manipulation, or unauthorized actions.

Technologies: [vega (npm)](https://junglewise.ai/threats/technologies/vega). Vendors: [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2025-59840 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2025-59840 being exploited in the wild.

**How severe is CVE-2025-59840?** High severity, with a CVSS score of 8.1, published 13 November 2025.

**Which products and versions are affected?** vega (npm) SEMVER:introduced=0,fixed=6.2.0; vega-expression (npm) SEMVER:introduced=6.0.0,fixed=6.1.0; vega-interpreter (npm) SEMVER:introduced=2.0.0,fixed=2.2.1.

**Is there a fix for CVE-2025-59840?** Yes. vega (npm): upgrade to 6.2.0 or later; vega-expression (npm): upgrade to 6.1.0 or later; vega-interpreter (npm): upgrade to 2.2.1 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2025-59840 attacked?** It is attacked over the network.

**Am I affected by CVE-2025-59840?** Check whether you run vega (npm), vega-expression (npm) or vega-interpreter (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- vega (npm): upgrade to 6.2.0 or later

  ```sh
  npm install vega@6.2.0
  ```

- vega-expression (npm): upgrade to 6.1.0 or later

  ```sh
  npm install vega-expression@6.1.0
  ```

- vega-interpreter (npm): upgrade to 2.2.1 or later

  ```sh
  npm install vega-interpreter@2.2.1
  ```


## Technical details

This is a DOM-based cross-site scripting (XSS) vulnerability in Vega that allows arbitrary code execution through expression evaluation. The root cause lies in the interaction between Vega's expression interpreter (which restricts direct function calls) and globally-exposed objects like VEGA_DEBUG. An attacker can craft a malicious Vega JSON specification containing a specially-crafted object that overrides the toString() method to invoke protected gadget functions (e.g., CanvasHandler.prototype.on) which ultimately call eval() with attacker-controlled code. Exploitation requires: (1) the Vega library and a View instance attached to the global window scope, and (2) the ability to supply a custom Vega JSON definition (e.g., via user upload or untrusted source). The vulnerability was patched in vega 6.2.0, vega-expression 6.1.0 (and 5.2.1 for non-ESM), and vega-interpreter 2.2.1.

## Affected products

- Vega Vega <=6.1.2
- Vega vega-expression <=6.0.0; <=5.2.0
- Vega vega-interpreter <=2.2.0; <=1.2.0

## Identifiers

- CVE-2025-59840
- GHSA-7f2v-3qq3-vvjf

## Timeline

- 2025-11-13: disclosed: Vulnerability disclosed via GHSA-7f2v-3qq3-vvjf
- 2025-11-13: patched: Patches released: vega 6.2.0, vega-expression 6.1.0/5.2.1, vega-interpreter 2.2.1/1.2.1

## References

- [https://github.com/vega/vega/security/advisories/GHSA-7f2v-3qq3-vvjf](https://github.com/vega/vega/security/advisories/GHSA-7f2v-3qq3-vvjf)

## Related threats

- [Vega cross-site scripting via RegExp.prototype[@@replace]](https://junglewise.ai/threats/cve-2025-27793-vega-cross-site-scripting-via-regexp-prototype-replace)
- [Vega Cross-Site Scripting via event filter in expression interpreter](https://junglewise.ai/threats/cve-2025-26619-vega-cross-site-scripting-via-event-filter-in-expression)
- [Vega cross-site scripting in vlSelectionTuples function](https://junglewise.ai/threats/cve-2025-25304-vega-cross-site-scripting-in-vlselectiontuples-function)
- [Vega arbitrary code execution via href links](https://junglewise.ai/threats/vega-arbitrary-code-execution-via-href-links-99e395dd)
- [Vega Expression Language scale function cross-site scripting](https://junglewise.ai/threats/cve-2023-26486-vega-expression-language-scale-function-cross-site-scripting)
