CVE-2026-68921
JSON

4.7medium

DiceBear: SVG injection via the unescaped rotate option in @dicebear/core (and fontSize/fontWeight in @dicebear/initials)

Severity
4.7medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.22% (higher than 13% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-gcr2-9v8m-gq45

Description

DiceBear is an avatar library for designers and developers. Prior to 9.4.3, @dicebear/core interpolates the rotate option into an SVG transform attribute without XML escaping in addRotate in packages/@dicebear/core/src/utils/svg.ts, while @dicebear/initials similarly emits fontSize and fontWeight without escaping in packages/@dicebear/initials/src/index.ts. Runtime callers can pass strings despite the numeric TypeScript types, break out of the attributes, and inject arbitrary SVG markup. Script can execute in the page origin when the generated avatar is inserted inline or served as image/svg+xml and opened directly, although exploitation requires an application to pass untrusted values into these normally developer-controlled options. This issue is fixed in @dicebear/core and @dicebear/initials version 9.4.3.

Affected

Product or packageVersionsReported by
dicebear dicebear< 9.4.3CVE List
@dicebear/core (npm)before 9.4.3GitHub Advisory Database
@dicebear/initials (npm)before 9.4.3GitHub Advisory Database

All scores

GitHub_M4.7medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
GitHub4.7medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N

Classification

CWE-79CWE-184

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

DiceBear is an avatar library for designers and developers. Prior to 9.4.3, @dicebear/core interpolates the rotate option into an SVG transform attribute without XML escaping in addRotate in packages/@dicebear/core/src/utils/svg.ts, while @dicebear/initials similarly emits fontSize and fontWeight without escaping in packages/@dicebear/initials/src/index.ts. Runtime callers can pass strings despite the numeric TypeScript types, break out of the attributes, and inject arbitrary SVG markup. Script can execute in the page origin when the generated avatar is inserted inline or served as image/svg+xml and opened directly, although exploitation requires an application to pass untrusted values into these normally developer-controlled options. This issue is fixed in @dicebear/core and @dicebear/initials version 9.4.3.

GitHub Advisory Database

Summary

@dicebear/core builds avatar SVGs from caller-supplied options. The numeric rotate option is interpolated into an SVG transform attribute without XML-escaping. It is typed as a number, but nothing checks the type at runtime, so a string value passes straight through and can break out of the attribute to inject arbitrary SVG markup.

This is the same root cause as CVE-2026-33311 (GHSA-mr9r-mww3-v6gv), which escaped the string options backgroundColor, fontFamily, and textColor but did not cover rotate. @dicebear/initials has the same gap in its numeric fontSize and fontWeight options.

Impact

Cross-site scripting (CWE-79). When the generated avatar is rendered inline (for example via innerHTML) or served as image/svg+xml and opened directly, injected markup such as an <image onerror> handler runs script in the page's origin.

Exploitation requires the application to pass untrusted input into one of these options:

  • rotate (@dicebear/core)
  • fontSize, fontWeight (@dicebear/initials)

In most integrations these options are set by the developer and only seed is user-controlled, so the vulnerable configuration is uncommon. Applications that use trusted, hardcoded values for these options are not at risk.

Patches

Fixed in @dicebear/core 9.4.3 and @dicebear/initials 9.4.3: the values are now XML-escaped before being written into the SVG, matching the CVE-2026-33311 fix. Upgrade to 9.4.3 or later.

The 5.x through 8.x lines share the same flaw but are end-of-life and will not receive a backport; upgrade to 9.4.3. The 10.x line is not affected.

Workarounds

If you cannot upgrade, coerce the affected options to a number before passing them to createAvatar:

rotate: Number(userInput) || 0,

Credits

Reported by @rz1027.

NVD (es)

DiceBear es una biblioteca de avatares para diseñadores y desarrolladores. Antes de la versión 9.4.3, @dicebear/core interpola la opción rotate en un atributo SVG transform sin escape XML en addRotate en packages/@dicebear/core/src/utils/svg.ts, mientras que @dicebear/initials emite de manera similar fontSize y fontWeight sin escape en packages/@dicebear/initials/src/index.ts. Los llamadores en tiempo de ejecución pueden pasar cadenas de texto a pesar de los tipos numéricos de TypeScript, salirse de los atributos e inyectar marcado SVG arbitrario. Se puede ejecutar script en el origen de la página cuando el avatar generado se inserta en línea o se sirve como image/svg+xml y se abre directamente, aunque la explotación requiere que una aplicación pase valores no confiables a estas opciones normalmente controladas por el desarrollador. Este problema está solucionado en las versiones 9.4.3 de @dicebear/core y @dicebear/initials.

References

Sources

SourceRecordLicence
CVE ListCVE-2026-68921 changed 2026-08-21CVE Terms of Use
GitHub Advisory DatabaseGHSA-gcr2-9v8m-gq45 changed 2026-09-17CC-BY-4.0
NVDCVE-2026-68921 changed 2026-10-26Public domain