XXE Vulnerability in php-dompdf: SSRF and Deserialization Risks

php-dompdf Updated 02 Oct 2025

Summary

15/11/2024
N/A
Yes i
Critical
9.8

CVE-2021-3902: An improper restriction of external entities (XXE) vulnerability in dompdf/dompdf's SVG parser allows for Server-Side Request Forgery (SSRF) and deserialization attacks. Affects php-dompdf across 2 version ranges.

< 2.0.2+dfsg-1 < f56bc8e40be6c0ae0825e6c7396f4db80620b799

Fixed in 2.0.2+dfsg-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

php-dompdf is a popular PHP library that converts HTML to PDF documents. It supports various features such as SVG rendering, font embedding, and image handling. However, the library has been found to have a vulnerability in its SVG parser that allows for improper handling of external entities, potentially exposing applications to security risks.

Vulnerability Detail

The vulnerability, identified as CVE-2021-3902, stems from an improper restriction of external entities (XXE) in the SVG parser of php-dompdf. This flaw allows attackers to exploit the library for Server-Side Request Forgery (SSRF) and deserialization attacks, even when the isRemoteEnabled option is set to false. The implications of this vulnerability include unauthorized access to internal image files and the potential for PHAR deserialization attacks, which can lead to remote code execution.

How To Fix

Minimum fixed version

2.0.2+dfsg-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade php-dompdf

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a temporary workaround, you can disable the SVG parsing feature if it is not essential for your application. This can be done by avoiding the use of SVG files in your PDF generation process until the library is updated.

Conclusion

The CVE-2021-3902 vulnerability in php-dompdf poses significant security risks due to its potential for SSRF and deserialization attacks. It is crucial for developers using this library to update to the patched version to mitigate these risks. Additionally, utilizing tools like Vulert can help monitor and alert for such vulnerabilities in real-time.

See every vulnerability recorded for php-dompdf →

Share this vulnerability

FAQ

CVE-2021-3902 is a vulnerability in the php-dompdf library that allows for SSRF and deserialization attacks due to improper handling of external entities in its SVG parser.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The risks include unauthorized access to internal resources, potential data exposure, and the ability to execute arbitrary code through deserialization attacks.

Yes, the vulnerability has been patched in version 2.0.2 of php-dompdf. It is recommended to update to this version or higher.

If an immediate update is not possible, consider disabling SVG parsing in your application as a temporary workaround until you can apply the patch.

Related vulnerabilities

Recent vulnerabilities recorded for php-dompdf.

How To Fix

Minimum fixed version

2.0.2+dfsg-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade php-dompdf

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback