CVE-2021-3838 is a critical (CVSS 9.8) PHAR deserialization flaw in Dompdf, the PHP HTML to PDF library, affecting versions before 2.0.0. An attacker who can place a file on the server may reach arbitrary object instantiation and possibly code execution. Upgrade to Dompdf 2.0.0 or later.
What's affected
- Dompdf (dompdf/dompdf) before version 2.0.0, per the NVD record and its description.
- Fixed in 2.0.0. The referenced upstream commit changes how Dompdf handles URI schemes, and the PHAR scheme is not enabled by default after the change.
- Highest risk where an application also lets users upload files of any type, and where a framework such as Laravel is present, because the record notes documented POP chains in such frameworks.
- No KEV listing: the record shows kev as false, and neither source we read reports exploitation in the wild.
How to check if you're exposed
Dompdf is usually pulled in through Composer, often as a transitive dependency of a reporting or invoicing package. These commands show the version and who requires it.
composer show dompdf/dompdf
composer why dompdf/dompdf
Any version below 2.0.0 is affected. Also look for code that passes user-controlled paths or URLs into Dompdf, and for upload features that accept arbitrary file types.
What to do now
- Run
composer update dompdf/dompdfafter raising the constraint incomposer.jsonto^2.0, then test your PDF templates, because 2.0.0 changed option handling. - Review how the new Options class is configured in your code. The commit moves protocol rules into that class, so any custom configuration needs a second look.
- Restrict uploads to the file types you actually need and store them outside paths that PHP functions can be pointed at by user input.
- Search your code for places where a user supplied value reaches a file or URL argument, and validate the scheme before use.
- Re-scan your lockfile to confirm that no other package still bundles an older Dompdf.
Why it matters
The weakness is CWE-502, deserialization of untrusted data. PHP can read metadata from a PHAR archive when a path starts with the phar scheme, and that metadata is turned back into live objects. If the application has classes that do something dangerous when created or destroyed, an attacker who controls the archive can steer those side effects. The record says Dompdf did not check the protocol before handing a path to file_get_contents, so the dangerous scheme could get through.
What makes this worse than a typical library bug is the dependence on the surrounding application. Dompdf itself does not need to contain the dangerous classes. A framework or plugin on the same server can supply them. That is why dependency inventories matter here: a PDF library you forgot you had can be the entry point.
Try it yourself
Click through it at your own pace, or open it full screen.
Quick check
Do I need file upload ability for this to be exploitable?
The record says the attacker needs to be able to upload files of any type to the server. If your application has no such feature and no other way to place files, the practical risk is lower, but upgrading is still the right call.
Is the fix just a version bump?
The fix is in 2.0.0, but the release changed how protocol rules and options are handled. Test your PDF output after upgrading.
Sources
- Upstream Dompdf commit referenced by the NVD record
- Huntr report listed in the record (not retrieved)
Last reviewed: 19 October 2026.