CVE-2026-33311: SVG Injection Vulnerability in @dicebear/core and @dicebear/initials
Summary
CVE-2026-33311: SVG Injection via Unsanitized Options in @dicebear/core and @dicebear/initials. Affects @dicebear/core across 5 version ranges.
>= 5.0.0, < 5.4.4
>= 6.0.0, < 6.1.4
>= 7.0.0, < 7.1.4
>= 8.0.0, < 8.0.3
>= 9.0.0, < 9.4.1
Fixed in 5 releases; the minimum fixed version depends on the release line you run. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The @dicebear/core and @dicebear/initials packages are widely used libraries for generating avatars in web applications. They allow developers to create customizable avatars using various options such as background color, font family, and text color. However, these packages have a vulnerability that arises from unsanitized user inputs, which can lead to security risks when rendering SVG images.
Vulnerability Detail
The vulnerability stems from the fact that SVG attribute values derived from user-supplied options (backgroundColor, fontFamily, textColor) were not properly XML-escaped before being interpolated into SVG output. This oversight can lead to Cross-Site Scripting (XSS) attacks if applications pass untrusted input directly to the createAvatar() function and serve the resulting SVG inline or with Content-Type: image/svg+xml. Attackers could exploit this vulnerability to execute arbitrary scripts in the context of the user's browser, potentially compromising user data and application integrity.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 5.0.0, < 5.4.45.4.4npm install @dicebear/core@5.4.4 -
>= 6.0.0, < 6.1.46.1.4npm install @dicebear/core@6.1.4 -
>= 7.0.0, < 7.1.47.1.4npm install @dicebear/core@7.1.4 -
>= 8.0.0, < 8.0.38.0.3npm install @dicebear/core@8.0.3 -
>= 9.0.0, < 9.4.19.4.1npm install @dicebear/core@9.4.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, applications can validate input against the library's JSON Schema before passing it to the createAvatar() function. This validation ensures that only trusted and sanitized input is used, thereby mitigating the risk of XSS attacks.
Conclusion
The SVG injection vulnerability in @dicebear/core and @dicebear/initials poses a significant risk to applications that utilize these libraries without proper input validation. By upgrading to the latest patched versions and implementing input validation, developers can secure their applications against potential XSS attacks.
See every vulnerability recorded for @dicebear/core →
FAQ
The vulnerability allows for SVG injection through unsanitized user inputs, potentially leading to XSS attacks.
The affected packages are @dicebear/core and @dicebear/initials.
You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without any signup.
The CVSS score of this vulnerability is 4.7, indicating a moderate severity level.
Upgrade to the patched versions of the affected packages and validate user inputs to prevent XSS attacks.
References
Related vulnerabilities
Recent vulnerabilities recorded for @dicebear/core.