VYPR
\n\n\n

Fabric.js SVG Export XSS Bypass Test (Gradient Color)

\n \n \n

SVG Output Rendering:

\n
\n\n \n\n\n```\n\n### Impact\n\nThis issue can lead to XSS in applications that:\n1. Allow user-controlled input in gradient definitions (e.g., color values)\n2. Use `canvas.toSVG()` to export content\n3. Insert the resulting SVG string into the DOM without sanitization (e.g., via `innerHTML`)\n\nSuccessful exploitation may result in the execution of arbitrary JavaScript in the victim's browser, theft of sensitive data, or unauthorized actions on behalf of the user.\n\n### Suggested Fix\n**Proper Escaping (Recommended)**: Escape special characters in attribute values during SVG serialization.","additionalType":"https://schema.org/SoftwareApplication","sameAs":["https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2026-44311"]},"keywords":"CVE-2026-44311, moderate, CWE-116, CWE-79, Fabrick Fabric.js","mentions":[{"@type":"SoftwareApplication","name":"Fabric.js","applicationCategory":"SecurityApplication","publisher":{"@type":"Organization","name":"Fabrick"}}],"isAccessibleForFree":true},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://portal.vyprsec.ai/"},{"@type":"ListItem","position":2,"name":"CVEs","item":"https://portal.vyprsec.ai/cves"},{"@type":"ListItem","position":3,"name":"CVE-2026-44311","item":"https://portal.vyprsec.ai/cves/CVE-2026-44311"}]}]}
Moderate severityGHSA Advisory· Published Jun 12, 2026· Updated Jun 12, 2026

Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization

CVE-2026-44311

Description

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 ` 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 `` elements like:


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: ``js color: 'red">' ``

may result in: ``xml ``

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>


   Fabric.js SVG Export XSS Bypass Test
   


   Fabric.js SVG Export XSS Bypass Test (Gradient Color)
   
   
   SVG Output Rendering:
   

   


Impact

This issue can lead to XSS in applications that: 1. Allow user-controlled input in gradient definitions (e.g., color values) 2. Use canvas.toSVG() to export content 3. Insert the resulting SVG string into the DOM without sanitization (e.g., via innerHTML)

Successful exploitation may result in the execution of arbitrary JavaScript in the victim's browser, theft of sensitive data, or unauthorized actions on behalf of the user.

Suggested

Fix Proper Escaping (Recommended): Escape special characters in attribute values during SVG serialization.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
fabricnpm
< 7.4.07.4.0

Affected products

1

Patches

Vulnerability mechanics

References

3

News mentions

0

No linked articles in our index yet.