/

CVE-2026-16766

Severity:

CRITICAL RISK

(9.8)

Shell Command Injection (CWE-78) in Perl Wkhtmltopdf View

CVE-2026-16766

Deferred

Vulnerability type

Category:

Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Catalyst::View::Wkhtmltopdf contains a shell command injection flaw where PDF render options are passed directly into the wkhtmltopdf command line without sanitization or validation.

When a web application forwards user-controlled options like page size, orientation, or margins to this component, an attacker can inject arbitrary shell commands and gain remote code execution on the server.

Catalyst::View::Wkhtmltopdf contains a shell command injection flaw where PDF render options are passed directly into the wkhtmltopdf command line without sanitization or validation.

When a web application forwards user-controlled options like page size, orientation, or margins to this component, an attacker can inject arbitrary shell commands and gain remote code execution on the server.

Affected context

This vulnerability manifests in Perl web applications that integrate Catalyst::View::Wkhtmltopdf to render HTML content as PDFs and dynamically build wkhtmltopdf command-line options from request parameters.

It becomes risky when user-controlled values such as page_size, orientation, margin settings, or other render options are passed through without strict validation, escaping, or whitelisting.

Deployments that run wkhtmltopdf with elevated privileges or on shared infrastructure are especially exposed, because the render process inherits the server's execution context.

This vulnerability manifests in Perl web applications that integrate Catalyst::View::Wkhtmltopdf to render HTML content as PDFs and dynamically build wkhtmltopdf command-line options from request parameters.

It becomes risky when user-controlled values such as page_size, orientation, margin settings, or other render options are passed through without strict validation, escaping, or whitelisting.

Deployments that run wkhtmltopdf with elevated privileges or on shared infrastructure are especially exposed, because the render process inherits the server's execution context.

Exploit preconditions

  • Attack surface: HTTP endpoints that trigger PDF generation using Catalyst::View::Wkhtmltopdf.
  • Required access: Ability to supply or influence PDF render options (e.g., query parameters, form fields, JSON payloads mapped to options).
  • Trigger point: Construction of the wkhtmltopdf command line where untrusted option values are concatenated or interpolated into a shell command.
  • Why exploitation is possible: Option strings are passed directly to the shell without sanitization or robust argument escaping, allowing injected metacharacters and command separators to be interpreted as additional commands.
  • Attack surface: HTTP endpoints that trigger PDF generation using Catalyst::View::Wkhtmltopdf.
  • Required access: Ability to supply or influence PDF render options (e.g., query parameters, form fields, JSON payloads mapped to options).
  • Trigger point: Construction of the wkhtmltopdf command line where untrusted option values are concatenated or interpolated into a shell command.
  • Why exploitation is possible: Option strings are passed directly to the shell without sanitization or robust argument escaping, allowing injected metacharacters and command separators to be interpreted as additional commands.

Why this happens

The underlying bug class is classic shell command injection, corresponding to CWE-78: Improper Neutralization of Special Elements used in an OS Command.

Catalyst::View::Wkhtmltopdf constructs a command to invoke wkhtmltopdf and treats option values as trusted, embedding them directly into the shell invocation without proper quoting, escaping, or argument-level handling.

This insecure pattern exposes the boundary between application data and executable commands: user input intended as configuration is instead interpreted by the shell as part of the command language, enabling arbitrary command execution under the web server's account.

The underlying bug class is classic shell command injection, corresponding to CWE-78: Improper Neutralization of Special Elements used in an OS Command.

Catalyst::View::Wkhtmltopdf constructs a command to invoke wkhtmltopdf and treats option values as trusted, embedding them directly into the shell invocation without proper quoting, escaping, or argument-level handling.

This insecure pattern exposes the boundary between application data and executable commands: user input intended as configuration is instead interpreted by the shell as part of the command language, enabling arbitrary command execution under the web server's account.

Potential impact

  • Remote execution of arbitrary OS commands under the web server or application user account.
  • Full compromise of the affected web application, including access to its configuration and runtime secrets.
  • Lateral movement within the host or network by leveraging the compromised process.
  • Data theft, modification, or destruction on the underlying system.
  • Use of the compromised server as a pivot for further attacks, such as installing backdoors or launching spam and phishing campaigns.
  • Remote execution of arbitrary OS commands under the web server or application user account.
  • Full compromise of the affected web application, including access to its configuration and runtime secrets.
  • Lateral movement within the host or network by leveraging the compromised process.
  • Data theft, modification, or destruction on the underlying system.
  • Use of the compromised server as a pivot for further attacks, such as installing backdoors or launching spam and phishing campaigns.

General mitigation guidance

Effective mitigation focuses on eliminating direct shell exposure for user-controlled values and narrowing the trust boundary around PDF render options.

Recommended patterns include:

  • Treating all render options as untrusted input and enforcing strict whitelists of allowed values (e.g., enumerated page sizes, orientations, and margin ranges).
  • Constructing wkhtmltopdf invocations using APIs or process-spawning mechanisms that pass arguments as arrays instead of shell-constructed strings, avoiding shell interpretation entirely.
  • Applying robust input validation and normalization to reject or sanitize characters with special meaning in shells, such as command separators, pipes, redirection operators, and subshell constructs.
  • Running PDF rendering services under highly constrained, least-privilege accounts, with limited filesystem and network access to reduce blast radius if an injection occurs.
  • Considering replacement of unmaintained components with actively supported libraries that offer secure-by-default interfaces for PDF generation.

Effective mitigation focuses on eliminating direct shell exposure for user-controlled values and narrowing the trust boundary around PDF render options.

Recommended patterns include:

  • Treating all render options as untrusted input and enforcing strict whitelists of allowed values (e.g., enumerated page sizes, orientations, and margin ranges).
  • Constructing wkhtmltopdf invocations using APIs or process-spawning mechanisms that pass arguments as arrays instead of shell-constructed strings, avoiding shell interpretation entirely.
  • Applying robust input validation and normalization to reject or sanitize characters with special meaning in shells, such as command separators, pipes, redirection operators, and subshell constructs.
  • Running PDF rendering services under highly constrained, least-privilege accounts, with limited filesystem and network access to reduce blast radius if an injection occurs.
  • Considering replacement of unmaintained components with actively supported libraries that offer secure-by-default interfaces for PDF generation.

How teams detect issues like this

Detection typically involves a mix of static inspection and runtime analysis:

  • Static code review looking for uses of Catalyst::View::Wkhtmltopdf where request parameters or other untrusted inputs are interpolated directly into command strings or option hashes.
  • Static analysis rules that flag shell invocation functions (e.g., system, backticks, open with |-, or similar process-spawning calls) when arguments are derived from HTTP request data without validation.
  • Application security testing (including DAST and fuzzing) that exercises PDF-related endpoints with payloads containing shell metacharacters to observe unexpected command execution or errors.
  • Policy-based enforcement in CI/CD to prevent adding new shell-based PDF rendering paths and to require security review for any code interacting with wkhtmltopdf or similar command-line tools.

Detection typically involves a mix of static inspection and runtime analysis:

  • Static code review looking for uses of Catalyst::View::Wkhtmltopdf where request parameters or other untrusted inputs are interpolated directly into command strings or option hashes.
  • Static analysis rules that flag shell invocation functions (e.g., system, backticks, open with |-, or similar process-spawning calls) when arguments are derived from HTTP request data without validation.
  • Application security testing (including DAST and fuzzing) that exercises PDF-related endpoints with payloads containing shell metacharacters to observe unexpected command execution or errors.
  • Policy-based enforcement in CI/CD to prevent adding new shell-based PDF rendering paths and to require security review for any code interacting with wkhtmltopdf or similar command-line tools.

Sources

SourceLink
github.comgithub.com/mc7244/Catalyst-View-Wkhtmltopdf/issues/6
github.comgithub.com/robrwo/Catalyst-View-Wkhtmltopdf/security/advisories/GHSA-42w4-jj8w-6p98
metacpan.orgmetacpan.org/release/RRWO/Catalyst-View-Wkhtmltopdf-v0.6.1/changes
wkhtmltopdf.orgwkhtmltopdf.org/status.html
openwall.comopenwall.com/lists/oss-security/2026/07/25/4

Frequently asked

questions

It is broadly exploitable wherever web applications expose PDF generation endpoints that accept user-supplied render options. If those options are forwarded directly to Catalyst::View::Wkhtmltopdf without strict validation, attackers can often reach the vulnerable code path via normal HTTP requests.

An attacker typically only needs the ability to send requests to the web application that influence PDF render options (such as page size or orientation). No direct shell access is required; the injection occurs when the server constructs the wkhtmltopdf command using those values.

The most robust fix is to stop building shell commands from user-controlled data altogether. Use process invocation APIs that pass arguments as structured arrays, impose strict whitelists and validation on all render options, and avoid any string concatenation of untrusted input into command lines. Where feasible, replace or wrap Catalyst::View::Wkhtmltopdf with a library or service designed with secure-by-default interfaces.

Prevention depends on consistently treating all external inputs as untrusted, avoiding shell interpretation of user data, and embedding these rules into development practices. Adopt secure coding guidelines that prohibit concatenating untrusted data into commands, enforce static analysis checks for risky patterns, and choose libraries that do not rely on shell-based execution for core functionality.

It is broadly exploitable wherever web applications expose PDF generation endpoints that accept user-supplied render options. If those options are forwarded directly to Catalyst::View::Wkhtmltopdf without strict validation, attackers can often reach the vulnerable code path via normal HTTP requests.

An attacker typically only needs the ability to send requests to the web application that influence PDF render options (such as page size or orientation). No direct shell access is required; the injection occurs when the server constructs the wkhtmltopdf command using those values.

The most robust fix is to stop building shell commands from user-controlled data altogether. Use process invocation APIs that pass arguments as structured arrays, impose strict whitelists and validation on all render options, and avoid any string concatenation of untrusted input into command lines. Where feasible, replace or wrap Catalyst::View::Wkhtmltopdf with a library or service designed with secure-by-default interfaces.

Prevention depends on consistently treating all external inputs as untrusted, avoiding shell interpretation of user data, and embedding these rules into development practices. Adopt secure coding guidelines that prohibit concatenating untrusted data into commands, enforce static analysis checks for risky patterns, and choose libraries that do not rely on shell-based execution for core functionality.

Find out what's already
exploitable in your codebase.