CVE-2026-49358: PhpWeasyPrint Arbitrary File Deletion via Unsafe Temporary File Cleanup
PhpWeasyPrint, a PHP library used to generate PDFs from URLs or HTML content, contains a flaw in how it manages temporary files. Before version 2.6.0, the list of temporary files is stored in a public variable that any code in the application can modify. When the library shuts down, it deletes every file listed in that variable without checking whether those files actually belong to the temporary folder. This means an attacker with code execution could trick the library into deleting arbitrary files on the system by adding them to the list. The vulnerability requires an attacker to have already compromised the application or have another way to run PHP code in the same process.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 3.0 LOW · CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:L/A:L
- Weaknesses (CWE)
- CWE-73
- Affected products
- 0 configuration(s)
- Published / Modified
- 2026-06-19 / 2026-06-23
NVD description (verbatim)
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.
5 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability stems from an insecure temporary file cleanup mechanism in PhpWeasyPrint versions prior to 2.6.0. The `AbstractGenerator::$temporaryFiles` array is declared as public, allowing any code with access to a generator instance to modify its contents. The `removeTemporaryFiles()` method, which executes both during object destruction (`__destruct()`) and via a registered PHP shutdown function, performs an `unlink()` operation on each array entry without path validation. Specifically, the code does not verify that paths are confined to the intended temporary directory before deletion. An attacker capable of maintaining a reference to an active generator instance can inject malicious file paths into the array, resulting in arbitrary file deletion when the script terminates. This design flaw mirrors a previously identified vulnerability in the KnpLabs/snappy project (GHSA-87qc-37cw-84h4) and represents improper resource disposal.
Business impact
The practical business impact is limited by the strict preconditions required for exploitation. An attacker must already have the ability to execute PHP code within the application's runtime context—a capability that typically indicates a prior compromise through another vector (e.g., code injection, deserialization flaw, or supply chain contamination). Given that requirement, the ability to delete files compounds the damage from that initial foothold. An attacker could delete application files, configuration files, or logs to cover tracks, escalate privilege within the application, or trigger a denial of service by removing critical system or application files. For organizations relying on PhpWeasyPrint for PDF generation in security-sensitive workflows, the risk is the secondary damage that follows successful initial compromise rather than an independent attack entry point.
Affected systems
PhpWeasyPrint versions prior to 2.6.0 are affected. The library is used in PHP applications that require server-side PDF generation capabilities. The vulnerability is present across all prior versions until the 2.6.0 release, which includes the security patch. No distinction is made between minor version numbers in the CVE record; all versions below 2.6.0 should be considered at risk.
Exploitability
Exploitation requires that an attacker already possess code execution capabilities within the PHP application—a significant barrier that limits this to post-compromise scenarios. The attack itself is straightforward once that access exists: an attacker maintaining a reference to the generator object can inject arbitrary file paths into the public `$temporaryFiles` array before the script exits. File deletion occurs automatically during shutdown without user interaction or additional prerequisites. The CVSS score of 3.0 (LOW severity) reflects this dependency on prior compromise; the vulnerability alone does not provide an attack entry point but rather extends the damage from an existing one. Practical exploitation would benefit from knowledge of the application's file structure and permissions, but blind attacks deleting common targets (e.g., `.htaccess`, configuration files) are feasible.
Remediation
Upgrade PhpWeasyPrint to version 2.6.0 or later. The patch restricts access to the temporary file list and adds path validation to the cleanup routine, ensuring that only files within the intended temporary directory are deleted. Organizations should verify the upgrade against the vendor advisory to confirm the specific patch applied. No workarounds exist within older versions; upgrading is the required remediation.
Patch guidance
Apply PhpWeasyPrint version 2.6.0 or newer as soon as practical. The patch is available from the official repository and package managers (e.g., Composer). Verify that your application's composer.json or equivalent dependency manifest is updated to require version 2.6.0 or a later stable release. Test the upgrade in a non-production environment to ensure compatibility with your specific use case before deploying to production. Given the LOW severity rating and the requirement for prior code execution, this can be scheduled with your regular patch cycle unless your environment has other known code execution risks that increase the urgency.
Detection guidance
Look for use of PhpWeasyPrint in your application inventory and check the installed version against 2.6.0 as a baseline. In a runtime detection sense, identify instances where external or untrusted input influences the creation of generator objects or could lead to references being shared across trust boundaries. Monitor for unexpected file deletion events in application logs or system audit trails, particularly deletions of application or configuration files during script shutdown. If you suspect exploitation, examine recent code commits or uploaded files for signs of compromise that preceded the file deletions. Endpoint or code analysis tools can flag public mutable attributes in dependency libraries as part of supply chain hygiene, though this is a preventive measure rather than post-exploit detection.
Why prioritize this
This vulnerability merits attention during regular patch cycles but does not demand emergency response. The LOW CVSS score (3.0) and the prerequisite of code execution already being present in the application mean that remediation should be balanced against other priorities. However, organizations with known code execution vulnerabilities in the same application or environment should prioritize this patch to limit the damage scope of those other flaws. Conversely, if your application is already running in a fully trusted environment with no prior code execution risks identified, the urgency is lower—though upgrading remains advisable as part of standard maintenance.
Risk score, explained
The CVSS 3.1 score of 3.0 (LOW) reflects the attack vector (Local), high attack complexity (code execution already required), high privileges (attacker must have prior compromise), and limited scope (same application context). The impact is rated as low integrity and low availability impact because while the attacker can delete files, the scope of deletable files is constrained by PHP process permissions and the attacker must already control code execution. The score acknowledges that this is a post-compromise amplification vector rather than a primary entry point, and that practical damage depends on file permissions, application architecture, and how critical the deleted files are to operations.
Frequently asked questions
Do I need to update if no one has access to my application?
Yes, you should still update PhpWeasyPrint to 2.6.0. While this vulnerability requires code execution to exploit, other unrelated vulnerabilities in your application or its dependencies might provide that entry point. Updating PhpWeasyPrint removes one additional risk from your attack surface and is part of good maintenance hygiene.
What files could an attacker delete?
An attacker could delete any file that the PHP process has permission to delete. This typically includes the application's own source files, configuration files, uploaded user files, and session data. The attacker could also delete log files to cover their tracks or delete critical application files to cause a denial of service. The exact impact depends on your file permissions, application structure, and what the attacker is motivated to destroy.
Is there a public exploit for this vulnerability?
The CVE record does not indicate public exploit code. However, exploitation is straightforward for anyone with code execution capabilities, and the pattern mirrors a previously disclosed flaw in another library. You should not rely on the absence of published exploits as a reason to delay patching.
Can I work around this if I cannot update immediately?
There is no reliable workaround within the vulnerable version. You could attempt to restrict which files the PHP process can access via OS-level permissions or containers, which would limit (but not eliminate) damage, but this is not a substitute for upgrading. Upgrade as soon as your deployment process allows.
This analysis is based on the official CVE record and the CVE description. Verify specific patch version numbers and deployment guidance against the official PhpWeasyPrint repository and vendor security advisories before applying updates to production systems. CVSS scores and severity ratings are drawn from the official CVSS 3.1 specification and NVD data. This document is provided for informational purposes and does not constitute legal, compliance, or specific deployment advice. Organizations should conduct their own risk assessment based on their specific environment, dependencies, and threat model. Source: NVD (public-domain), retrieved 2026-07-27. Analysis generated by SEC.co (claude-haiku-4-5).
Weaknesses (CWE)
Related vulnerabilities
- CVE-2025-12656LOWWPvivid Plugin Arbitrary Directory Deletion Vulnerability
- CVE-2025-52465HIGHGeoServer Master Password Plaintext Dump Vulnerability
- CVE-2026-10303HIGHServerCo getssl ACME Token Validation Flaw Enables Path Traversal
- CVE-2026-10558MEDIUMSourceCodester Pizzafy 1.0 File Inclusion Vulnerability – Admin RCE Risk
- CVE-2026-10559MEDIUMFile Inclusion in SourceCodester Pizzafy Ecommerce System 1.0
- CVE-2026-10694HIGHRemote File Inclusion in SourceCodester Online Food Ordering System 2.0
- CVE-2026-11527HIGHConfig::IniFiles Command Injection and File Overwrite Vulnerability
- CVE-2026-20175MEDIUMCisco Finesse Remote File Injection via Client-Side Request Validation Bypass