Safeguard
Vulnerability Analysis•

CVE-2021-3902: Critical XXE and SSRF in Dompdf SVG Parser

CVE-2021-3902 is an XXE flaw in the Dompdf SVG parser that enables SSRF and PHAR deserialization before 2.0.0, even with remote disabled. Upgrade to 2.0.0.

Safeguard Security Team
3 min read

CVE-2021-3902 is a critical (CVSS 9.8) XML external entity flaw in the SVG parser of Dompdf, the PHP PDF library. It allows server side request forgery and PHAR deserialization in all versions before 2.0.0, even when isRemoteEnabled is false. Upgrade to Dompdf 2.0.0 or later.

What's affected

  • Dompdf (dompdf/dompdf), all versions before 2.0.0, per the NVD record.
  • Fixed in 2.0.0, which is the version both this and the related CVE-2021-3838 point to.
  • The record states the issue can be exploited even when the isRemoteEnabled option is false, so disabling remote access is not a mitigation.
  • Applications that render user supplied SVG images into PDFs are the obvious exposure. Be careful about assuming you are safe because you do not accept SVG directly, since SVG can arrive inside HTML.
  • KEV status: false in the record.

How to check if you're exposed

Find where Dompdf is installed and at what version.

composer show dompdf/dompdf
composer why dompdf/dompdf

Then check whether any feature of your application passes user content, including HTML with embedded or linked SVG, into Dompdf. Those paths decide whether the parser is reachable.

What to do now

  1. Raise the Dompdf constraint to ^2.0 and run composer update dompdf/dompdf.
  2. Regression test any PDF that includes SVG graphics, since the parser handling changed.
  3. Sanitize or reject user supplied SVG and HTML before it reaches the PDF step.
  4. Review outbound network rules for the application host. Server side request forgery is much less useful when internal services are not reachable from the web tier.
  5. Patch CVE-2021-3838 in the same change, since both are fixed by the same upgrade.

Why it matters

The class is CWE-611, improper restriction of XML external entity references. An XML parser that resolves external entities can be told to fetch a local file or a URL as part of reading a document. Here the record says that behavior leads to server side request forgery, disclosure of internal image files, and PHAR deserialization attacks.

The notable detail is that the setting meant to block remote resources did not block this path. That is a reminder that a safe looking option is not a control until you have confirmed it covers every parser in the library. The upgrade is the reliable fix.

Try it yourself

Click through it at your own pace, or open it full screen.

Quick check

Does setting isRemoteEnabled to false protect me?

No. The record says the issue can be exploited even with that option set to false.

Is this the same bug as CVE-2021-3838?

No. Both are fixed in Dompdf 2.0.0, but this one is an XXE flaw in the SVG parser, while the other is PHAR deserialization through missing protocol checks.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

We email you a link to confirm, and only then add you to the list. Unsubscribe in one click. Privacy

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.