# CVE-2022-40440: mxGraph cross-site scripting in setTooltips function

Source: https://junglewise.ai/threats/cve-2022-40440-mxgraph-cross-site-scripting-in-settooltips-function  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2022-10-12. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2022-40440 · Severity: low · CVSS 3.1 · Published 2022-10-12

mxGraph is a JavaScript library for building interactive diagrams and flowcharts in web applications. A cross-site scripting vulnerability in the tooltip feature allows attackers to inject malicious scripts that execute when a user hovers over diagram elements, potentially compromising user data or session security.

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

## Quick answers

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

**How severe is CVE-2022-40440?** Low severity, with a CVSS score of 3.1, published 12 October 2022.

**Which products and versions are affected?** mxgraph (npm) SEMVER:introduced=0,last_affected=4.2.2.

**Is there a fix for CVE-2022-40440?** No fixed version is recorded yet. Check the vendor's advisory in the references below. If you run it, Junglewise drafts a mitigation that fits your setup and applies it once you approve, with senior security engineers behind it.

**How is CVE-2022-40440 attacked?** It is attacked over the network.

**Am I affected by CVE-2022-40440?** Check whether you run mxgraph (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.

## Technical details

The vulnerability is a stored cross-site scripting (XSS) flaw in mxGraph's setTooltips() function that fails to properly sanitize user-supplied content before rendering it via innerHTML. When the setTooltips feature is enabled, the mxTooltipHandler uses innerHTML to display custom cell values without sanitization, allowing attackers to inject arbitrary HTML/JavaScript. The attack requires no authentication and is triggered through user interaction (hovering over a diagram element). An attacker can inject malicious code into cell values (e.g., &lt;iframe src=javascript:alert(1)&gt;) that executes in the victim's browser when tooltips are displayed. The vulnerability affects mxGraph version 4.2.2 and likely all earlier versions; patch status is unclear from available sources.

## Affected products

- jgraph mxGraph through 4.2.2

## Identifiers

- CVE-2022-40440
- GHSA-j4rv-pr9g-q8jv

## Timeline

- 2022-10-12: disclosed

## References

- [https://github.com/SxB64/mxgraph-xss-vul/wiki](https://github.com/SxB64/mxgraph-xss-vul/wiki)

## Related threats

- [mxGraph cross-site scripting in color field](https://junglewise.ai/threats/cve-2019-13127-mxgraph-cross-site-scripting-in-color-field)
- [mxGraph XXE vulnerability in XML parsing](https://junglewise.ai/threats/cve-2017-18197-mxgraph-xxe-vulnerability-in-xml-parsing)
