# CVE-2026-33311: @dicebear/core and @dicebear/initials Vulnerable to SVG Injection via Unsanitized Options

> Attackers can inject malicious scripts via unsanitized SVG options in DiceBear, leading to XSS if applications serve generated SVGs inline.

- **Severity:** Medium 4.7 (`CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 24 Mar 2026
- **Updated:** 26 Mar 2026
- **Also known as:** GHSA-mr9r-mww3-v6gv

## What is CVE-2026-33311?

CVE-2026-33311 is a medium-severity cross-site scripting vulnerability in dicebear, published on 24 Mar 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

DiceBear is an avatar library for designers and developers. Starting in version 5.0.0 and prior to versions 5.4.4, 6.1.4, 7.1.4, 8.0.3, and 9.4.1, SVG attribute values derived from user-supplied options (`backgroundColor`, `fontFamily`, `textColor`) were not XML-escaped before interpolation into SVG output. This could allow Cross-Site Scripting (XSS) when applications pass untrusted input to `createAvatar()` and serve the resulting SVG inline or with `Content-Type: image/svg+xml`. Starting in versions 5.4.4, 6.1.4, 7.1.4, 8.0.3, and 9.4.1, all affected SVG attribute values are properly escaped using XML entity encoding. Users should upgrade to the listed patched versions. Some mitigating factors limit vulnerability. Applications that validate input against the library's JSON Schema before passing it to `createAvatar()` are not affected. The DiceBear CLI validates input via AJV and was not vulnerable. Exploitation requires that an application passes untrusted, unvalidated external input directly as option values.

Weakness: CWE-79 (Improper Neutralization of Input During Web Page Generation)

## Which versions are affected by CVE-2026-33311?

20 open source packages ship an affected version, including @dicebear/core and @dicebear/initials. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@dicebear/core` | npm | From 5.0.0 | 5.4.4 |
| `@dicebear/core` | npm | From 5.0.0 | 5.4.4 |
| `@dicebear/core` | npm | From 6.0.0 | 6.1.4 |
| `@dicebear/core` | npm | From 6.0.0 | 6.1.4 |
| `@dicebear/core` | npm | From 7.0.0 | 7.1.4 |
| `@dicebear/core` | npm | From 7.0.0 | 7.1.4 |
| `@dicebear/core` | npm | From 8.0.0 | 8.0.3 |
| `@dicebear/core` | npm | From 8.0.0 | 8.0.3 |
| `@dicebear/core` | npm | From 9.0.0 | 9.4.1 |
| `@dicebear/core` | npm | From 9.0.0 | 9.4.1 |
| `@dicebear/initials` | npm | From 5.0.0 | 5.4.4 |
| `@dicebear/initials` | npm | From 5.0.0 | 5.4.4 |
| `@dicebear/initials` | npm | From 6.0.0 | 6.1.4 |
| `@dicebear/initials` | npm | From 6.0.0 | 6.1.4 |
| `@dicebear/initials` | npm | From 7.0.0 | 7.1.4 |
| `@dicebear/initials` | npm | From 7.0.0 | 7.1.4 |
| `@dicebear/initials` | npm | From 8.0.0 | 8.0.3 |
| `@dicebear/initials` | npm | From 8.0.0 | 8.0.3 |
| `@dicebear/initials` | npm | From 9.0.0 | 9.4.1 |
| `@dicebear/initials` | npm | From 9.0.0 | 9.4.1 |

Products: Dicebear Dicebear.

## How do I fix CVE-2026-33311?

Upgrade @dicebear/core to a fixed version for your release line: 5.4.4, 6.1.4, 7.1.4 or 8.0.3.

## Is CVE-2026-33311 being exploited?

There is no known exploitation of CVE-2026-33311 in the wild and no public exploit code.

## Other vulnerabilities in dicebear

- [CVE-2026-33418](https://insights.sbomify.com/CVE-2026-33418/): @dicebear/converter ensureSize() Vulnerable to SVG Dimension Capping Bypass via XML Comment Injection (high 7.5)
- [CVE-2026-29112](https://insights.sbomify.com/CVE-2026-29112/): @dicebear/converter vulnerable to ncontrolled memory allocation via crafted SVG dimensions (high 7.5)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-33311 and fix it if it is affected.

What it is: CVE-2026-33311 is a medium-severity cross-site scripting vulnerability in dicebear, published on 24 Mar 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of CVE-2026-33311 in the wild and no public exploit code.

Affected packages and fixed versions:
- @dicebear/core (npm): affected from 5.0.0; fixed in 5.4.4
- @dicebear/core (npm): affected from 5.0.0; fixed in 5.4.4
- @dicebear/core (npm): affected from 6.0.0; fixed in 6.1.4
- @dicebear/core (npm): affected from 6.0.0; fixed in 6.1.4
- @dicebear/core (npm): affected from 7.0.0; fixed in 7.1.4
- @dicebear/core (npm): affected from 7.0.0; fixed in 7.1.4
- @dicebear/core (npm): affected from 8.0.0; fixed in 8.0.3
- @dicebear/core (npm): affected from 8.0.0; fixed in 8.0.3
- @dicebear/core (npm): affected from 9.0.0; fixed in 9.4.1
- @dicebear/core (npm): affected from 9.0.0; fixed in 9.4.1
- @dicebear/initials (npm): affected from 5.0.0; fixed in 5.4.4
- @dicebear/initials (npm): affected from 5.0.0; fixed in 5.4.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-33311/ (Markdown: https://insights.sbomify.com/CVE-2026-33311/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-33311
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-33311
- OSV: https://osv.dev/vulnerability/CVE-2026-33311

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-33311/
Summaries are generated and may contain mistakes; the official description above is the record.
