{"id":"CVE-2026-33418","aliases":["CVE-2026-33418","GHSA-7j2x-32w6-p43p"],"related":[],"kind":"vulnerability","state":"published","title":"@dicebear/converter ensureSize() Vulnerable to SVG Dimension Capping Bypass via XML Comment Injection","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe `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.\n\n## Details\n\nThe vulnerable function used `String.prototype.replace()` with a non-global regex to find and rewrite the first `<svg` tag's dimensions. Since the regex does not distinguish between `<svg` appearing inside non-element XML constructs and the actual SVG root element, a crafted input can cause the regex to match a decoy instead of the real element, leaving the actual SVG dimensions unclamped.\n\nIn the Node.js rendering path, `renderAsync` from `@resvg/resvg-js` was called without a `fitTo` constraint, so it would render at whatever dimensions the SVG element specified — potentially allocating gigabytes of memory.\n\nThe browser code path is **not** vulnerable because it uses the clamped `size` return value from `ensureSize()` to set `canvas.width` and `canvas.height` directly.\n\n## Impact\n\nAny application that passes untrusted or user-supplied SVG content through `@dicebear/converter`'s Node.js conversion functions (`toPng`, `toJpeg`, `toWebp`, `toAvif`) is vulnerable to denial of service via excessive memory allocation. Note that `@dicebear/converter` can be used independently of DiceBear's avatar generation — any SVG string can be passed to the conversion functions.\n\nThe impact is limited to availability — there is no data disclosure or integrity impact. The browser code path is not affected.\n\n## Fix\n\nThe 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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"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 `","source":"nvd"}],"published":"2026-03-20T20:35:40.000Z","modified":"2026-06-17T10:37:27.807Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-185"],"affected":[{"ranges":[{"version":"< 9.4.2","status":"affected"}],"vendor":"dicebear","product":"dicebear","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"9.4.2"}],"ecosystem":"npm","package":"@dicebear/converter","purl":"pkg:npm/%40dicebear/converter","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"9.4.2"}],"vendor":"dicebear","product":"dicebear","cpe":"cpe:2.3:a:dicebear:dicebear:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/dicebear/dicebear/security/advisories/GHSA-7j2x-32w6-p43p","tags":["mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33418","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/dicebear/dicebear","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-03-24T14:10:31.935Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-33418","url":"https://www.cve.org/CVERecord?id=CVE-2026-33418","licence":"CVE Terms of Use","modified":"2026-03-24T15:11:51.489Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-7j2x-32w6-p43p","url":"https://github.com/advisories/GHSA-7j2x-32w6-p43p","licence":"CC-BY-4.0","modified":"2026-03-25T21:05:05.061Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-33418","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-33418","licence":"Public domain","modified":"2026-06-17T10:37:27.807Z"}],"updatedAt":"2026-11-25T22:59:16.563Z","epss":{"score":0.00415,"percentile":0.37786,"date":"2026-12-01T12:00:22.000Z"}}