CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-68921

CVE-2026-68921: Cross-Site Scripting via SVG Attribute Injection in DiceBear

Amit Schendel
Amit Schendel
Senior Security Researcher

Sep 3, 2026·7 min read·21 visits

Executive Summary (TL;DR)

A runtime type bypass in `@dicebear/core` and `@dicebear/initials` allows unescaped string payloads to be processed in place of numeric parameters, causing structural breakout in the generated SVG and enabling stored cross-site scripting.

CVE-2026-68921 is a Cross-Site Scripting (XSS) vulnerability affecting the `@dicebear/core` and `@dicebear/initials` packages. The flaw stems from a disconnect between compile-time TypeScript type definitions and runtime JavaScript execution. Unvalidated numeric-typed options can receive raw string payloads at runtime, allowing attackers to escape XML attribute boundaries and inject malicious vector markup, executing arbitrary script code within the user's web origin.

Vulnerability Overview

The avatar generation library DiceBear, specifically within the @dicebear/core and @dicebear/initials packages, contains a Cross-Site Scripting (XSS) and SVG Injection vulnerability. These packages programmatically construct Scalable Vector Graphics (SVG) assets using user-specified configuration values. Because SVGs support active content such as inline scripts, style elements, and event handlers, the structural integrity of the generated XML output must be rigidly protected.

In typical web architectures, backend services utilize libraries like DiceBear to serve dynamic user avatars on-the-fly. These applications frequently map query-string values, route parameters, or database attributes directly to library properties. If these values are not verified or sanitized, an attacker can pass raw injection strings. This exposes an attack surface where structurally destructive text payloads alter the downstream browser parser's execution flow.

The vulnerability is classified under CWE-79 (Improper Neutralization of Input During Web Page Generation) and CWE-184 (Incomplete List of Disallowed Inputs). The core flaw manifests when numeric customization attributes are used inside formatting templates. Because SVGs are parsed as active XML documents, an attacker who successfully injects attributes or elements can bypass standard cross-site scripting filters.

Root Cause Analysis

The root cause of this vulnerability lies in an architectural assumption regarding type enforcement. The @dicebear/core and @dicebear/initials packages are authored in TypeScript, which enforces strict static typing at compile-time. Variables such as rotate in @dicebear/core, and fontSize and fontWeight in @dicebear/initials are defined explicitly as number types. Under static analysis, this typing suggests to developers that string-based payloads cannot penetrate these fields.

However, once compiled to JavaScript for execution in a Node.js or browser runtime, all TypeScript static type declarations are stripped away. JavaScript execution runtimes do not perform automatic runtime type assertion on assigned values. If an upstream application accepts raw query parameters directly from an HTTP request (such as req.query.rotate in Express, which parses strings) and passes them to the library without explicit conversion or validation, string values are fed directly into the DiceBear generation methods.

Because the library expected these properties to always be numeric, it bypassed the standard XML escaping function (escapeXml) for these specific variables, interpolating them directly as template literals. When the parser constructs the SVG markup, any unescaped string parameter containing characters like quotes or angle brackets alters the XML layout. The browser's XML parser interprets these characters as layout tokens, terminating the active attribute, and initiating a new, attacker-defined element.

Code Analysis

To understand the structural failure, we analyze the vulnerable code path in @dicebear/core/src/utils/svg.ts. The addRotate utility interpolates the rotate parameter directly into a transform attribute string without escaping:

// Vulnerable implementation in @dicebear/core
export function addRotate(result: StyleCreateResult, rotate: number) {
  let { width, height, x, y } = getViewBox(result);
 
  return `<g transform="rotate(${rotate}, ${width / 2 + x}, ${
    height / 2 + y
  })">${result.body}</g>`;
}

A similar vulnerability exists in @dicebear/initials/src/index.ts, where numeric options like fontSize and fontWeight are interpolated directly into a text element, while other string parameters are properly escaped:

// Vulnerable implementation in @dicebear/initials
const svg = [
  `<text x="50%" y="50%" font-family="${escapeXml(fontFamily)}" font-size="${fontSize}" font-weight="${fontWeight}" fill="${escapeXml(textColor)}" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${escapeXml(initials)}</text>`,
].join('');

The fix, introduced in commit 922946d738c4e77ab6c412e27ede75941fec4b59, forces these numeric properties to undergo XML sanitization. The updated codebase casts the numeric variables to strings and routes them through the appropriate XML escape helper. In @dicebear/core, the code is modified as follows:

// Patched implementation in @dicebear/core
export function addRotate(result: StyleCreateResult, rotate: number) {
  let { width, height, x, y } = getViewBox(result);
 
  return `<g transform="rotate(${escape.xml(`${rotate}`)}, ${width / 2 + x}, ${
    height / 2 + y
  })">${result.body}</g>`;
}

This patch is complete and structurally sound. By applying escape.xml() or escapeXml(), any malicious character sequences such as double-quotes, ampersands, or angle brackets are safely mapped to their safe XML entity equivalents (e.g., &quot;, &lt;), neutralizing the injection potential before the browser parser processes the SVG.

Exploitation

Exploitation of CVE-2026-68921 depends on the victim application directly mapping user input to vulnerable DiceBear parameters. The attack scenario typically involves an API endpoint that generates dynamic avatars using query parameters. An attacker can construct a payload designed to escape the XML attribute boundaries and execute arbitrary JavaScript.

For the @dicebear/core vector, an attacker targets the rotate option. By passing the payload 0)"/><image href="y" onerror="alert(document.domain)"/><g transform="rotate(0, the rendered XML is manipulated as follows:

<g transform="rotate(0)"/><image href="y" onerror="alert(document.domain)"/><g transform="rotate(0, 50, 50)">[SVG BODY]</g>

When the victim loads a web page that renders this SVG inline, or accesses the raw SVG directly, the browser parses the unescaped <image> element. The browser fails to resolve the malformed source href="y", immediately triggering the onerror handler and executing the injected JavaScript code in the security context of the hosting origin.

For @dicebear/initials, an attacker targets fontSize or fontWeight with the payload 50" x="0" onload="alert(1)" data-x=". This breaks the text element context to append an active script trigger:

<text x="50%" y="50%" font-family="Arial" font-size="50" x="0" onload="alert(1)" data-x="" font-weight="400" ...>[INITIALS]</text>

The script execution context differs based on how the SVG is delivered. If the SVG is loaded via a standard <img> tag, modern browsers apply strict isolation policies that block internal script execution. However, if the SVG is rendered inline within the HTML Document Object Model, or served directly as an image/svg+xml document, the script fires, compromising the session.

Impact Assessment

The concrete impact of successful exploitation is stored or reflected Cross-Site Scripting (XSS) within the victim application's domain context. An attacker who executes arbitrary script code can read sensitive browser storage, access local credentials, hijack session tokens (including JWTs and non-HttpOnly cookies), and manipulate the active DOM.

Because the scope of the vulnerability changes from the generated XML markup to client-side script execution, the CVSS v3.1 scope metric is classified as Changed (S:C). The vulnerability has a CVSS base score of 4.7 (Medium). The score is moderate because exploitation requires high attack complexity (AC:H); the upstream developer must build an integration that allows end-users to control parameters intended to be static or programmatically restricted.

Despite the moderate CVSS score, if an application displays user-defined avatars on dashboard interfaces viewed by administrators, the exploit allows horizontal or vertical privilege escalation. The attacker could hijack administrative sessions to execute high-privilege operations, posing a significant risk in shared enterprise platforms.

Remediation

Remediation requires updating all dependencies referencing @dicebear/core and @dicebear/initials to version 9.4.3 or higher. This upgrade forces structural escaping on all potentially vulnerable paths. In instances where upgrading is not immediately possible, strict input boundaries must be established.

To implement defensive validation in code, wrap any parameters passed to DiceBear in an explicit parsing and type checking structure. Rather than trusting compile-time interfaces, parse all inputs strictly using run-time validation libraries or manual casting before execution:

// Defensive coding pattern to validate inputs at the runtime boundary
function sanitizeAvatarOptions(reqQuery) {
  const sanitized = {};
  if (reqQuery.rotate) {
    const rotateVal = parseInt(reqQuery.rotate, 10);
    sanitized.rotate = isNaN(rotateVal) ? 0 : rotateVal;
  }
  if (reqQuery.fontSize) {
    const sizeVal = parseInt(reqQuery.fontSize, 10);
    sanitized.fontSize = isNaN(sizeVal) ? 50 : sizeVal;
  }
  return sanitized;
}

Additionally, apply infrastructure-level defenses such as strict Content Security Policies (CSP). Disable unsafe-inline scripts and define object-src 'none'. If serving SVGs via dynamic server endpoints, set protective HTTP response headers to isolate the generated asset:

Content-Type: image/svg+xml
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline';

Official Patches

DiceBearFix commit implementing strict XML escaping on numerical attributes.

Fix Analysis (1)

Technical Appendix

CVSS Score
4.7/ 10
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N
EPSS Probability
0.22%
Top 87% most exploited

Affected Systems

@dicebear/core@dicebear/initials

Affected Versions Detail

Product
Affected Versions
Fixed Version
@dicebear/core
DiceBear
< 9.4.39.4.3
@dicebear/initials
DiceBear
< 9.4.39.4.3
AttributeDetail
CWE IDCWE-79
Attack VectorNetwork
CVSS v3.1 Score4.7 (Medium)
EPSS Score0.00222
ImpactCross-Site Scripting (XSS)
Exploit StatusProof-of-Concept (PoC)
CISA KEV StatusNot Listed

MITRE ATT&CK Mapping

T1189Drive-by Compromise
Initial Access
T1185Browser Session Hijacking
Collection
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

Known Exploits & Detection

GitHub Security AdvisoryProof of concept and technical description detailing attribute breakouts on rotate, fontSize, and fontWeight.

Vulnerability Timeline

Patch commit applied to DiceBear repository.
2026-07-05
DiceBear version 9.4.3 released containing the security fix.
2026-08-20
GitHub Security Advisory GHSA-gcr2-9v8m-gq45 published.
2026-08-20
CVE-2026-68921 assigned and published by GitHub CNA.
2026-08-20
National Vulnerability Database (NVD) processed and indexed the record.
2026-08-21

References & Sources

  • [1]NVD - CVE-2026-68921 Detail
  • [2]DiceBear Security Advisory GHSA-gcr2-9v8m-gq45
  • [3]DiceBear v9.4.3 Release Notes
  • [4]CVE.org Record

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•2 minutes ago•CVE-2026-109619
9.2

CVE-2026-109619: Remote Code Execution in PHP Core via Stale Global State Memory Corruption (PHP2Shell)

CVE-2026-109619 (PHP2Shell) is a critical Use-After-Free vulnerability in the core PHP engine caused by improper global state cleanup during out-of-memory exception handling across persistent worker requests.

Alon Barad
Alon Barad
1 views•6 min read
•5 minutes ago•CVE-2026-113721
4.5

CVE-2026-113721: Unsafe Link Resolution in virtualenv File Generation

In Python virtualenv prior to version 21.14.9, activation script generators and configuration writers use Path.exists() before writing files. Because Path.exists() resolves symbolic links, it returns False for dangling symlinks. Consequently, virtualenv skips unlinking pre-planted symbolic links or hard links, writing data directly to target locations outside the intended virtual environment directory.

Amit Schendel
Amit Schendel
1 views•5 min read
•9 days ago•CVE-2026-87697
8.8

CVE-2026-87697: Untrusted Deserialization in .NET PresentationCore Clipboard Handling

A remote code execution vulnerability exists in Microsoft .NET due to untrusted data deserialization within the PresentationCore component. The flaw stems from implicit auto-conversion flags during clipboard data retrieval operations.

Alon Barad
Alon Barad
31 views•5 min read
•9 days ago•CVE-2026-70007
8.8

CVE-2026-70007: Out-of-Bounds Write Vulnerability in .NET Framework and WPF Subsystem

An out-of-bounds write vulnerability in Microsoft .NET Framework, .NET runtime, and Visual Studio allows unauthenticated remote attackers to execute arbitrary code via crafted pixel-shader bytecode or auto-converted clipboard payloads.

Amit Schendel
Amit Schendel
19 views•6 min read
•10 days ago•CVE-2026-70186
7.5

CVE-2026-70186: ASP.NET Core Denial of Service Vulnerability via Framework Deadlock

ASP.NET Core contains a thread deadlock vulnerability (CWE-833) that allows an unauthenticated remote attacker to cause a denial of service over the network by exhausting server thread pool resources.

Amit Schendel
Amit Schendel
18 views•5 min read
•10 days ago•CVE-2026-70035
8.8

CVE-2026-70035: Insecure Deserialization Remote Code Execution in Microsoft .NET Framework and .NET Runtime

CVE-2026-70035 is a high-severity Remote Code Execution (RCE) vulnerability in Microsoft .NET Framework, .NET runtime, and Visual Studio caused by improper handling during the deserialization of untrusted data (CWE-502). An unauthenticated attacker can execute arbitrary code within the context of the affected process by delivering a crafted serialized payload.

Amit Schendel
Amit Schendel
24 views•6 min read