Description
Fabric.js is a Javascript HTML5 canvas library. Prior to 7.4.0, a potential Cross-Site Scripting (XSS) vulnerability exists in Fabric.js due to improper escaping of user-controlled input during SVG serialization via the toSVG() method. Specifically, the color field within the colorStops array of a fabric.Gradient object is not properly escaped when converted into SVG <stop> elements. If an application renders the generated SVG string into the DOM, this may allow an attacker to inject arbitrary HTML/SVG and execute JavaScript in the victim's browser. This vulnerability is fixed in 7.4.0.
Published: 2026-06-22
Score: 5.4 Medium
EPSS: n/a
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

Fabric.js allows rendering visual objects to an SVG string using the toSVG() method. In versions prior to 7.4.0 this library fails to escape the contents of the color field within the colorStops array of a fabric.Gradient object. The unescaped value is inserted directly into <stop> elements of the SVG. If an application renders this SVG string into the DOM without further sanitization, an attacker can inject arbitrary HTML or JavaScript, gaining the privileges of the page and potentially exfiltrating data or modifying page behavior. The flaw leads to a classic client‑side XSS issue, affecting confidentiality, integrity and potentially availability of the web application.

Affected Systems

The vulnerability affects the Fabric.js library for JavaScript from the fabricjs project. All releases earlier than 7.4.0 are impacted. Versions 7.4.0 and newer contain the fix and are not susceptible.

Risk and Exploitability

The nominal CVSS score of 5.4 indicates moderate severity. The EPSS score is not available, so the likelihood of exploitation is unknown from statistical models, but the vulnerability is publicly documented and can be crafted by an attacker who has control over the data passed to toSVG(). The vulnerability is not listed in CISA's KEV catalog, suggesting no known exploitation in the wild at the time of analysis. The attack vector is most efficiently achieved by an attacker who can influence the objects sent to toSVG(), for example via user input or backend manipulation of the graphics data. If the output is embedded in a web page, the attacker can execute arbitrary JavaScript in the context of that page.

Generated by OpenCVE AI on June 22, 2026 at 23:31 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Fabric.js to version 7.4.0 or later to apply the official patch.
  • If upgrading is not immediately possible, ensure that any SVG output generated by toSVG() is sanitized or escaped before inserting it into the DOM to prevent script execution.
  • Review application code to verify that user‑controlled input is not used in the colorStops array or, if it is required, that the values are properly validated and encoded against markup injection.

Generated by OpenCVE AI on June 22, 2026 at 23:31 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-w22m-hvvm-xmwx Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization
History

Tue, 23 Jun 2026 01:30:00 +0000

Type Values Removed Values Added
First Time appeared Fabricjs
Fabricjs fabric.js
Vendors & Products Fabricjs
Fabricjs fabric.js

Mon, 22 Jun 2026 22:00:00 +0000

Type Values Removed Values Added
Description Fabric.js is a Javascript HTML5 canvas library. Prior to 7.4.0, a potential Cross-Site Scripting (XSS) vulnerability exists in Fabric.js due to improper escaping of user-controlled input during SVG serialization via the toSVG() method. Specifically, the color field within the colorStops array of a fabric.Gradient object is not properly escaped when converted into SVG <stop> elements. If an application renders the generated SVG string into the DOM, this may allow an attacker to inject arbitrary HTML/SVG and execute JavaScript in the victim's browser. This vulnerability is fixed in 7.4.0.
Title Fabric.js: Improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization
Weaknesses CWE-116
CWE-79
References
Metrics cvssV3_1

{'score': 5.4, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N'}


Subscriptions

Fabricjs Fabric.js
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-06-22T20:50:56.690Z

Reserved: 2026-05-05T19:00:06.021Z

Link: CVE-2026-44311

cve-icon Vulnrichment

No data.

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-06-23T01:15:16Z

Weaknesses
  • CWE-116

    Improper Encoding or Escaping of Output

  • CWE-79

    Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')