/

CVE-2025-66648

Severity:

HIGH RISK

(7.2)

Cross-Site Scripting (XSS) in vega-functions

CVE-2025-66648

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Client-Side Code Execution / Cross-Site Scripting

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

vega-functions contained an internal expression function that could be abused to execute unintended JavaScript when processing untrusted user input.

In deployments where end users can control Vega expressions, this bug could lead to cross-site scripting (XSS) in the context of the embedding web application.

Affected context

This vulnerability arises in applications that embed Vega and rely on vega-functions to evaluate expressions derived from untrusted or partially trusted user input.

It is particularly relevant where:

  • Users can define or influence Vega specifications, data transforms, or expressions.
  • The application assumes that using vega.expressionInterpreter or CSP-safe modes is sufficient to prevent arbitrary script execution.
  • The internal (non-public) function remains reachable through the expression language, even though it is not part of the intended API surface.

In such setups, the browser environment executing Vega becomes a vehicle for XSS against the hosting page.

Exploit preconditions

  • Attack surface: Web applications that render Vega visualizations using vega-functions in the browser or similar client contexts.
  • Required access: Ability to supply or modify Vega expressions, specifications, or other inputs that are processed by the Vega expression engine (e.g., via dashboards, shared reports, custom chart builders, or saved configs).
  • Trigger point: Evaluation of a crafted expression that calls or indirectly reaches the internal function exposed through the expression runtime.
  • Why exploitation is possible: The expression engine exposes an internal function that permits or results in arbitrary JavaScript execution, bypassing expectations that the interpreter and CSP-safe modes fully sandbox expression evaluation.

Why this happens

The core issue is a trust boundary failure between user-controlled expression input and the internal implementation of the Vega expression language.

An internal function, not intended to be part of the public API, remained reachable within the expression evaluation environment.

Because the expression engine did not sufficiently restrict which functions were exposed to untrusted expressions, an attacker could reference this internal function to execute JavaScript in the page context.

This maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), with the nuance that the injection vector is the data-driven expression system rather than direct HTML or script template construction.

Potential impact

  • Execution of arbitrary JavaScript in the victim's browser within the origin of the embedding application.
  • Theft of sensitive data accessible to the page, such as session tokens, CSRF tokens, or user-specific API responses.
  • Unauthorized actions performed on behalf of the user (e.g., state changes, form submissions, or API calls).
  • Manipulation of visualizations to misrepresent data or perform phishing-like UI redressing within dashboards.
  • Pivoting into further client-side attacks using the compromised scripting context.

General mitigation guidance

Effective mitigation centers on reducing the capabilities and reach of the expression language and treating user-supplied expressions as untrusted code:

  • Constrain expression environments so only a minimal, whitelisted set of safe functions is exposed to user-controlled expressions; internal or powerful primitives should be unreachable.
  • Treat all user-controllable Vega specs, transforms, and expressions as untrusted and apply policy checks before execution (e.g., ban or strip dangerous constructs and function names).
  • Layer defenses by combining strict expression sandboxing with browser security controls such as strong Content Security Policy, avoiding reliance on single mechanisms like interpreters alone.
  • Separate roles and privileges so only trusted actors can define complex or global expressions, while untrusted users are limited to safer configuration parameters.
  • Prefer safe-by-default embedding patterns that render untrusted visualizations in constrained contexts (e.g., iframes with reduced permissions) where appropriate.

How teams detect issues like this

Detection efforts can focus on both code and runtime behavior:

  • Static analysis and review:
  • Examine expression engines and DSL interpreters for exposure of internal or non-public functions to user input.
  • Flag patterns where user-supplied strings are evaluated by interpreters that can resolve names or access ambient objects.
  • Review bindings between visualization libraries and the host page for any bridging functions that can lead to script execution.
  • Policy and automated checks:
  • Implement linting or CI rules that prevent adding new expression-accessible functions without explicit review.
  • Use security-focused code scanning tools configured to understand custom expression evaluators and sandbox boundaries.
  • Runtime monitoring:
  • Instrument client-side error logging and Content Security Policy reports to detect unexpected script execution or blocked inline scripts related to Vega usage.

Sources

SourceLink
github.comgithub.com/vega/vega/security/advisories/GHSA-m9rg-mr6g-75gm

Frequently asked

questions

Yes, if an application exposes interfaces where remote users can supply or influence Vega expressions, a remote attacker can craft a payload that triggers XSS when the visualization is rendered in a victim's browser.

The attacker must be able to control or modify data that is fed into the Vega expression engine—such as report definitions, saved dashboards, shared visualization specs, or any user-editable configuration that the application passes to Vega.

The safest pattern is to strictly separate internal implementation functions from the public expression surface, exposing only a small, vetted set of safe operations. Any function capable of evaluating arbitrary JavaScript or interacting with the host environment should be inaccessible to untrusted expressions.

When designing or integrating expression languages and DSLs, treat them as potential code execution interfaces: minimize available capabilities, enforce function whitelists, perform security-focused reviews of new expression features, and complement these controls with robust browser-side defenses like restrictive CSP and, where possible, isolated rendering contexts.

Find out what's already
exploitable in your codebase.