Summary
A stored cross-site scripting vulnerability in Chartbrew versions 4.9.0 through 5.0.0 allows project editors to inject arbitrary HTML and JavaScript via the ChartDatasetConfig.legend field.
Because this content is later inserted into the tooltip DOM using innerHTML without sanitization, any visitor to a public dashboard can have attacker-controlled JavaScript executed in their browser on page load.
Affected context
The issue appears in Chartbrew deployments where:
- Versions 4.9.0 through 5.0.0 are in use
- Project members have editor permissions and can define or modify chart dataset configuration
- Dashboards are shared publicly or broadly within an organization
- Tooltips are rendered using Chart.js and the
ChartTooltip.jscomponent assigns tooltip content withinnerHTML
In this context, attacker-controlled legend text flows from the ChartDatasetConfig.legend field, through the Chart.js rendering pipeline, and into the tooltip element that is displayed automatically when charts load.
Exploit preconditions
- Attack surface: Web-based Chartbrew dashboards, especially public or widely shared dashboards.
- Required access: Authenticated access with at least project-editor permissions to create or modify chart dataset configuration.
- Primary trigger point: Page load or initial chart rendering of a dashboard containing a malicious legend value; no user hover or click interaction is necessary.
- Why exploitation is possible: User-supplied text from
ChartDatasetConfig.legendis stored verbatim in the database, not validated or sanitized for HTML/JavaScript, and is later written directly into the tooltip DOM element viaelement.innerHTML. This enables embedded script or event-handler attributes to execute in the context of the viewer's origin.
Why this happens
This vulnerability stems from unsafe handling of user-controlled content in a UI rendering path.
The ChartDatasetConfig.legend field accepts arbitrary text from project editors and persists it directly to storage without enforcing an HTML-safe encoding or performing robust sanitization.
During dashboard rendering, Chartbrew passes this legend value through the Chart.js integration, where a tooltip component (ChartTooltip.js) inserts the content into the DOM using innerHTML instead of a text-only API.
This pattern maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), where user-controlled input is used to generate HTML without proper escaping, allowing attackers to inject script tags, event handlers, or other active content.
Potential impact
- Attacker-controlled JavaScript can run in the victim's browser within the Chartbrew application origin.
- Theft of session tokens, CSRF tokens, or other sensitive data accessible to front-end scripts may occur.
- Unauthorized actions can be performed on behalf of the victim (stored CSRF-style behavior) using the victim's established session.
- Defacement or manipulation of dashboard content and visualizations could mislead viewers or hide malicious activity.
- Use of the vulnerability as a pivot for broader attacks, such as delivering further payloads or probing internal applications via the victim's browser.
General mitigation guidance
Effective mitigation focuses on breaking the direct path from user-controlled data to executable HTML or script execution:
- Treat all chart configuration fields, including legend text, as untrusted input and encode/escape them before inserting into the DOM.
- Replace
innerHTMLwith text-safe APIs (e.g.,textContentor equivalent) for tooltip and legend rendering, unless strictly necessary to support limited HTML. - If some markup must be supported, apply a robust, allowlist-based HTML sanitizer that strips script tags, event handlers, JavaScript URLs, and other executable constructs.
- Normalize data flow so that visual configuration values are processed through centralized encoding utilities rather than ad-hoc string concatenation in UI components.
- Reduce the privileges of project-editor roles where possible, and limit who can modify chart configurations on dashboards with large or untrusted audiences.
- Adopt a secure-by-default component pattern where all UI components expect encoded data, and any deviation must be explicitly justified and reviewed.
How teams detect issues like this
Detection can combine code-level analysis with application behavior monitoring:
- Static code analysis: Search for use of
innerHTML,dangerouslySetInnerHTML, template literals, or other HTML injection points that receive data from chart configuration or other user-supplied fields. - Data-flow review: Trace the flow from inputs like
ChartDatasetConfig.legend(and similar configuration fields) to UI rendering, ensuring either encoding or sanitization is applied before DOM insertion. - Code review practices: Include XSS-specific review checklists for any changes to tooltip, annotation, label, or legend rendering logic, especially when integrating with charting libraries.
- Automated scanning: Use dynamic application security testing tools or browser automation (e.g., Playwright, Selenium) to inject benign XSS test payloads into configuration fields and observe whether they appear as executable content in the DOM.
- Security linting and policies: Enforce lint rules or framework-specific security policies that flag direct DOM manipulation with untrusted data during CI.

