CVE-2026-49358 PhpWeasyPrint vulnerable to arbitrary file deletion at shutdown via public $temporaryFiles

Low 3.0 Published Updated

Attackers can delete arbitrary files by injecting paths into a public array, affecting applications using PhpWeasyPrint for PDF generation.

Exploited in the wild
Not known
Login needed
An administrator
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2026-49358?

CVE-2026-49358 is a low-severity path traversal vulnerability in pontedilana php-weasyprint, published on 19 Jun 2026. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

PhpWeasyPrint is a PHP library allowing PDF generation from a URL or an HTML page. Prior to version 2.6.0, `AbstractGenerator::$temporaryFiles` is a public array, and `removeTemporaryFiles()` — invoked from `__destruct()` and from a registered shutdown function — calls `unlink()` on every entry without verifying that the path is contained within the temporary folder. Any code holding a reference to a generator instance can push an arbitrary path into the array and have it deleted on script shutdown. This mirrors the KnpLabs/snappy issue GHSA-87qc-37cw-84h4. PhpWeasyPrint version 2.6.0 contains a patch for the issue.

Weakness: CWE-73

Which versions are affected by CVE-2026-49358?

2 open source packages ship an affected version, including pontedilana/php-weasyprint.

PackageAffectedFixed in
pontedilana/php-weasyprint PackagistAll versions2.6.0
pontedilana/php-weasyprint PackagistAll versions2.6.0

How do I fix CVE-2026-49358?

Upgrade pontedilana/php-weasyprint to 2.6.0 or later.

Upgrade, and resolve every user-supplied path against an allowed base folder before opening it. More about Path traversal.

Is CVE-2026-49358 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-49358 exists.

Sources

Also known as GHSA-5g9f-cwwg-4p8g.

Is CVE-2026-49358 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free