CVE-2026-68921: DiceBear: SVG injection via the unescaped rotate option in @dicebear/core (and fontSize/fontWeight in @dicebear/initials)
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 Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
@dicebear/coreto a version that resolves this vulnerability.Fixed in 9.4.3 - Upgrade
Upgrade
@dicebear/initialsto a version that resolves this vulnerability.Fixed in 9.4.3
Event History
Frequently Asked Questions
Which deployments are realistically exposed?
Applications using @dicebear/core before 9.4.3 are exposed if they pass attacker-controlled values to rotate. Applications using @dicebear/initials before 9.4.3 are exposed if they pass attacker-controlled values to fontSize or fontWeight, and render the resulting SVG inline or serve it as image/svg+xml for direct opening.
What must an attacker control for exploitation?
The attacker must be able to cause the application to supply a string value to one of the affected options, despite their numeric TypeScript types. They also need the generated SVG to be rendered in a context where injected SVG script can execute in the page origin.
Are normal default uses affected?
The issue requires untrusted input to reach normally developer-controlled avatar options. The provided information does not indicate that default option values alone trigger the vulnerability.
What can be done if upgrading is not immediately possible?
Do not pass untrusted values to rotate, fontSize, or fontWeight. Enforce numeric validation and reject values that are not valid numbers before generating the SVG; upgrade both affected packages to version 9.4.3 when possible.
How can an application determine whether it is at risk?
Review calls that generate DiceBear avatars for user- or request-controlled data reaching rotate, fontSize, or fontWeight. Also identify whether generated SVG is inserted inline or served as image/svg+xml and opened directly, as those rendering paths can allow script execution.