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.expressionInterpreteror 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.

