CVE-2026-33418: @dicebear/converter SVG Dimension Capping Bypass Vulnerability

HIGH
Advisory Identifier: GHSA-7j2x-32w6-p43p
CVSS 7.5
CWE-185
Published
Advisory Summary

CVE-2026-33418 is a HIGH (CVSS 7.5) svg dimension capping bypass vulnerability (CWE-185: Incorrect Regular Expression) affecting @dicebear/converter libraries in the npm ecosystem. The issue involves svg dimension capping bypass via xml comment injection in @dicebear/converter ensuresize(). Remediation is available by upgrading affected packages to version 9.4.2.

CVE-2026-33418 at a Glance

CVE Identifier CVE-2026-33418
GHSA Identifier GHSA-7j2x-32w6-p43p
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-185: Incorrect Regular Expression
Affected Product @dicebear/converter
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-33418

To remediate this vulnerability, upgrade all affected @dicebear/converter dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@dicebear/converter fixed: 9.4.2
npm install @dicebear/converter@9.4.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @dicebear/converter

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-33418, inspect your project dependencies using npm:

npm ls @dicebear/converter

Analyze the terminal output to locate any version of @dicebear/converter in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.4.2), your application is affected.

Note: The npm ls @dicebear/converter command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-185: Incorrect Regular Expression, where the product specifies a regular expression in a way that causes data to be improperly matched or compared. In @dicebear/converter, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary 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. ## Details The 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. In 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. The browser code path is **not** vulnerable because it uses the clamped `size` return value from `ensureSize()` to set `canvas.width` and `canvas.height` directly. ## Impact Any 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. The impact is limited to availability — there is no data disclosure or integrity impact. The browser code path is not affected. ## Fix 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.

CVE-2026-33418 Affected @dicebear/converter Versions

1 component(s)
Fixed Versions:
9.4.2
Product / Package Ecosystem Affected Versions Fixed Version
@dicebear/converter
npm
< 9.4.2
9.4.2

References

Frequently Asked Questions

What is CVE-2026-33418?
CVE-2026-33418 is a security vulnerability in @dicebear/converter involving SVG Dimension Capping Bypass via XML Comment Injection in @dicebear/converter ensureSize() under CWE-185: Incorrect Regular Expression.
Which @dicebear/converter versions are affected?
Affected versions include releases prior to 9.4.2 across affected packages: @dicebear/converter.
What version fixes CVE-2026-33418?
Upgrading to 9.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @dicebear/converter affected?
Yes, @dicebear/converter is affected in releases prior to 9.4.2. Upgrade your dependency to 9.4.2 or later.
What is the CVSS score of CVE-2026-33418?
CVE-2026-33418 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-33418?
CVE-2026-33418 is classified under CWE-185: Incorrect Regular Expression (The product specifies a regular expression in a way that causes data to be improperly matched or compared.).
How can I check npm dependencies for CVE-2026-33418?
Run the dependency tree command: 'npm ls @dicebear/converter'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7j2x-32w6-p43p",
  "modified" : "2026-03-25T20:53:40Z",
  "published" : "2026-03-20T20:35:40Z",
  "aliases" : [ "CVE-2026-33418" ],
  "summary" : "SVG Dimension Capping Bypass via XML Comment Injection in @dicebear/converter ensureSize()",
  "details" : "## 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.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@dicebear/converter"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.4.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 9.4.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dicebear/dicebear/security/advisories/GHSA-7j2x-32w6-p43p"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-33418"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dicebear/dicebear"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-185" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-20T20:35:40Z",
    "nvd_published_at" : "2026-03-24T14:16:30Z"
  }
}