CVE-2026-49260: PhpWeasyPrint Shell Command Injection via Binary Path
PhpWeasyPrint is a widely-used PHP library that generates PDF files from web pages or HTML content. A critical flaw in versions before 2.5.1 allows attackers with elevated privileges on a server to inject arbitrary shell commands by manipulating the WeasyPrint binary path. The vulnerability exists because the code incorrectly validates the binary path—it quotes the path, then checks if the quoted version exists as a file (which it never will), bypassing the safety check entirely. This means the unvalidated path flows directly into system command execution, giving an attacker a direct pathway to run malicious commands. The issue stems from a design flaw the library inherited from a similar codebase that was previously patched elsewhere.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 8.2 HIGH · CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
- Weaknesses (CWE)
- CWE-78
- Affected products
- 0 configuration(s)
- Published / Modified
- 2026-06-19 / 2026-06-22
NVD description (verbatim)
PhpWeasyPrint is a PHP library allowing PDF generation from a URL or an HTML page. Prior to version 2.5.1, `pontedilana/php-weasyprint` builds the shell command for WeasyPrint by passing the binary path through `escapeshellarg()` first and then checking the *quoted* result with `is_executable()`. On POSIX `escapeshellarg('/usr/local/bin/weasyprint')` returns `'/usr/local/bin/weasyprint'` with the single-quote characters as part of the string, so `is_executable()` looks for a file whose actual name includes those quotes. That file never exists, the "safe" branch is dead code, and the raw `$binary` string (set via the constructor or `setBinary()`) flows directly into `Symfony\Component\Process\Process::fromShellCommandline()`. Any deployment whose binary path is sourced from configuration, an environment variable, or a per-tenant setting reaches a shell-command-injection sink. The library is documented as a one-to-one substitute for KnpLabs/snappy and inherited the exact pre-fix codepath KnpLabs patched in GHSA-vpr4-p6fq-85jc. PhpWeasyPrint version 2.5.1 contains a patch for the issue.
6 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
The vulnerability is a shell command injection flaw in the PhpWeasyPrint library's binary path handling. The affected code uses `escapeshellarg()` to quote the WeasyPrint binary path, then calls `is_executable()` on the quoted string. Because `escapeshellarg()` adds single quotes to the path itself—for example, converting `/usr/local/bin/weasyprint` to the literal string `'/usr/local/bin/weasyprint'`—the `is_executable()` check looks for a file whose name includes quote characters. This file does not exist, so the safety branch never executes. The raw, unquoted binary path from the constructor or `setBinary()` method is passed directly to `Symfony\Component\Process\Process::fromShellCommandline()`, which interprets shell metacharacters. Any attacker who can control the binary path through configuration files, environment variables, or multi-tenant settings can inject shell commands that execute with the privileges of the PHP process.
Business impact
Organizations deploying PhpWeasyPrint in multi-tenant environments or configurations where the binary path is externally controlled face elevated risk. A compromised administrator account, misconfigured access controls, or a supply-chain compromise could allow attackers to execute arbitrary code on affected servers. This can lead to data theft, lateral movement within the network, service disruption, and compliance violations. The impact is amplified in SaaS platforms or shared hosting scenarios where a single server serves multiple customers. Immediate patching is strongly recommended for production systems, particularly those with user-controlled or dynamic binary path configurations.
Affected systems
Any deployment of PhpWeasyPrint prior to version 2.5.1 is vulnerable. The risk is highest in systems where the WeasyPrint binary path originates from configuration management, environment variables, or per-tenant settings rather than hardcoded values. This includes web applications, document generation services, report engines, and any system that dynamically configures the PDF generation backend. Organizations using alternative configurations or forks of the library should verify their specific versions against the upstream patch.
Exploitability
Exploitation requires an attacker with elevated privileges (High Privilege requirement per the CVSS vector), meaning they must already have significant access to the system—such as an administrator account, privileged process, or ability to modify configuration files and environment variables. However, the barrier to exploitation is low once this access is achieved; the attacker need only set the binary path to a malicious value such as `/bin/bash; touch /tmp/pwned; #` to execute arbitrary commands. No authentication bypass or user interaction is required. In multi-tenant or shared infrastructure scenarios, the privilege threshold may be lower than expected (e.g., a tenant admin modifying their own configuration).
Remediation
Upgrade PhpWeasyPrint to version 2.5.1 or later immediately. Version 2.5.1 corrects the binary path validation logic to properly verify that the (unquoted) path is executable before passing it to the shell command builder. Organizations should verify the patch version against official vendor releases and test in a staging environment before deploying to production. For systems that cannot be patched immediately, restrict write access to configuration files and environment variables that control the binary path to only highly trusted administrators, and audit access logs for unauthorized modifications.
Patch guidance
Update the `pontedilana/php-weasyprint` package to version 2.5.1 or later. If you manage dependencies via Composer, run `composer update pontedilana/php-weasyprint` to pull the patched version. Verify the update in your `composer.lock` file to confirm version 2.5.1 or higher is installed. Test PDF generation functionality in a non-production environment to ensure compatibility with your application before rolling out to production. If you maintain a private mirror or vendored copy of the library, apply the patch from the upstream repository and re-deploy. No configuration changes are required after upgrading; the fix is transparent to calling code.
Detection guidance
Monitor for suspicious modifications to configuration files that control the WeasyPrint binary path (e.g., `.env` files, YAML/JSON configuration, environment variable exports). Audit privileged account activity and configuration management tool logs for unexpected changes to the binary path setting. Inspect running PHP processes and their command-line arguments using `ps` or process monitoring tools for signs of shell metacharacters in the binary path. Review PHP error logs and application logs for unexpected system command output or errors originating from the PDF generation module. If you have comprehensive logging, search for any invocation of `setBinary()` or constructor calls with untrusted data. In multi-tenant environments, implement per-tenant audit trails and alert on modifications to shared infrastructure settings.
Why prioritize this
Although the CVSS score is 8.2 (HIGH) and the vulnerability requires High privilege to exploit, the combination of high impact (code execution with service privileges), relative ease of exploitation once privileged access is obtained, and the critical role PDF generation often plays in business workflows warrants immediate patching. The flaw is not a novel attack; it replicates a previously-patched vulnerability in a related library, indicating that defensive measures may already exist in some organizations but were not carried forward when this library was adopted. Prioritize environments that expose binary path configuration to multiple administrators or automated systems, or that serve multiple tenants.
Risk score, explained
The CVSS:3.1 score of 8.2 reflects a HIGH severity vulnerability with local attack vector, low attack complexity, high-privilege requirement, and scope change that enables impact to other systems. The score appropriately captures the severity of arbitrary code execution. However, the real-world risk depends heavily on your deployment model: hardcoded binary paths in code significantly lower risk, while dynamic configuration or multi-tenant scenarios elevate it. The vulnerability is not currently tracked on the CISA Known Exploited Vulnerabilities (KEV) catalog, but the architectural flaw is well-understood and easily exploitable once access is achieved.
Frequently asked questions
Does this vulnerability affect hardcoded WeasyPrint paths?
No. If your application hard-codes the binary path as a literal string in the source code and never modifies it, the attack surface is eliminated. The vulnerability only manifests when the binary path is sourced from configuration files, environment variables, constructor parameters, or runtime settings that an attacker with High privilege can manipulate.
Is this vulnerability active in the wild or in the CISA KEV list?
No, the vulnerability is not currently listed in the CISA Known Exploited Vulnerabilities catalog. However, it is a straightforward code execution flaw that mirrors a previously-patched vulnerability in a related library, so it should be treated as a high-priority fix regardless of current exploit activity.
What should I do if I cannot upgrade immediately?
Restrict write access to all configuration sources that control the binary path (environment files, config files, database records) to only the most trusted administrators. Implement file integrity monitoring on these configurations and alert on any unexpected changes. Use SELinux, AppArmor, or similar mandatory access controls to limit what the PHP process can execute. Consider running the PDF generation service in a sandboxed container with minimal privileges as a temporary measure.
Does the patch break existing code or require configuration changes?
No. The patch is purely a bug fix to the binary path validation logic. Existing code that calls PhpWeasyPrint continues to work unchanged, and no configuration modifications are needed after upgrading. The fix is transparent to your application.
This analysis is provided for informational purposes and reflects publicly available information as of the publication date. CVSS scores and vulnerability classifications are based on vendor disclosures and do not constitute a guarantee of severity in your specific environment. Real-world risk depends on your deployment model, privilege controls, and configuration management practices. Always verify patch availability and compatibility with your specific version before deploying updates. If you use a fork, derivative, or private mirror of PhpWeasyPrint, you are responsible for independently applying the patch or working with your maintainer. This document does not constitute professional security advice; consult your security team for guidance specific to your infrastructure. Source: NVD (public-domain), retrieved 2026-07-27. Analysis generated by SEC.co (claude-haiku-4-5).
Weaknesses (CWE)
Related vulnerabilities
- CVE-2025-41265HIGHWaterfall WF-500 TX Host OS Command Injection (CVSS 7.2)
- CVE-2025-41266HIGHWaterfall WF-500 TX Host Command Injection Vulnerability Analysis
- CVE-2025-41267HIGHWaterfall WF-500 TX Host Command Injection Vulnerability
- CVE-2025-41279HIGHOS Command Injection in Waterfall WF-500 RX Host Administration WebUI
- CVE-2025-41281HIGHWaterfall WF-500 OS Command Injection
- CVE-2025-66273HIGHQNAP Command Injection in QTS and QuTS hero
- CVE-2025-66279HIGHQNAP NAS Command Injection – Admin Authentication Required, HIGH Severity
- CVE-2025-69755HIGHNeterbit NW-431F Router RCE and Data Exposure Vulnerability