Vulnerability library
Security checkJuly 18, 2026

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

Understand the exposure, see the recommended fix, and check whether your own website has related weaknesses.

Medium severitynpmfabric

Check your website

Find this and other vulnerabilities with a free scan.

Your scan runs on your computer. No account required.

Description

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.

Recommendation

Update the fabric package to the latest compatible version. Followings are version details:

  • Affected version(s): < 7.4.0
  • Patched version(s): 7.4.0

References

Could your website be exposed too?

SmartScanner can check your website for Fabric.js improper escaping in fabric.Gradient colorStops leads to XSS in SVG serialization and gives you actionable findings to investigate.

Start a free scan

Related Issues

See something that needs correcting? Let us knowUpdated July 18, 2026