CVE-2026-46643: Snappy Binary Path Is Never Shell-escaped Vulnerability

HIGH
Advisory Identifier: GHSA-vpr4-p6fq-85jc
CWE-78
Published
Advisory Summary

CVE-2026-46643 is a HIGH binary path is never shell-escaped vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Snappy libraries in the Packagist ecosystem. The issue involves binary path is never shell-escaped due to an inverted is_executable check. Remediation is available by upgrading affected packages to version 1.7.1.

CVE-2026-46643 at a Glance

CVE Identifier CVE-2026-46643
GHSA Identifier GHSA-vpr4-p6fq-85jc
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Snappy
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix CVE-2026-46643

To remediate this vulnerability, upgrade all affected Snappy dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

KnpLabs/knp-snappy fixed: 1.7.1
Upgrade KnpLabs/knp-snappy to 1.7.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for KnpLabs/knp-snappy

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-46643, inspect your project dependencies for Snappy:

inspect dependencies for KnpLabs/knp-snappy

Analyze the terminal output to locate any version of Snappy in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.7.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Snappy, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact On POSIX, escapeshellarg(‘/usr/bin/wkhtmltopdf’) returns the literal string ‘/usr/bin/wkhtmltopdf’ with the single-quote characters included. is_executable() then looks for a file whose actual name contains those quote characters, which essentially never exists. The safe branch is dead code and $command always falls through to the raw, unescaped value. The rest of the arguments (options, input, output) are escaped correctly, so injection has to land in the binary string itself. That happens whenever the binary path is sourced from configuration that is user-influenced, derived from environment variables that ultimately come from request data, or concatenated with any user-controlled fragment. #### Proof of concept: ```php $pdf = new Knp\Snappy\Pdf(‘wkhtmltopdf; touch /tmp/snappy_rce’); $pdf->generate(‘https://example.com’, ‘/tmp/out.pdf’); // /tmp/snappy_rce is created. ``` **Impact:** command execution as the PHP process when the binary path is attacker-influenced. Even in deployments where the binary is hard-coded, this is a defensive-in-depth regression: downstream packages reasonably assume Snappy shell-escapes the binary because the code looks like it does. ### Patches The version 1.7.1 will resolve this security advisory. ### Workarounds Before calling the constructor, ensure `\is_executable($path)` is truthy. ```php // Bad example $pdf = new Knp\Snappy\Pdf('/path/to/binary'); ``` ```php // Better example $pathToBinary = '/path/to/binary'; if (!\is_executable($pathToBinary)) { throw new \RuntimeException(); } $pdf = new Knp\Snappy\Pdf('/path/to/binary'); ```

CVE-2026-46643 Affected Snappy Versions

1 component(s)
Fixed Versions:
1.7.1
Product / Package Ecosystem Affected Versions Fixed Version
KnpLabs/knp-snappy
Packagist
< 1.7.1
1.7.1

References

Frequently Asked Questions

What is CVE-2026-46643?
CVE-2026-46643 is a security vulnerability in Snappy involving Binary path is never shell-escaped due to an inverted is_executable check under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Snappy versions are affected?
Affected versions include releases prior to 1.7.1 across affected packages: KnpLabs/knp-snappy.
What version fixes CVE-2026-46643?
Upgrading to 1.7.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is KnpLabs/knp-snappy affected?
Yes, KnpLabs/knp-snappy is affected in releases prior to 1.7.1. Upgrade your dependency to 1.7.1 or later.
What CWE is associated with CVE-2026-46643?
CVE-2026-46643 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check Packagist dependencies for CVE-2026-46643?
Run the dependency tree command: 'inspect dependencies for KnpLabs/knp-snappy'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-vpr4-p6fq-85jc",
  "modified" : "2026-06-11T13:30:23Z",
  "published" : "2026-05-21T20:22:16Z",
  "aliases" : [ "CVE-2026-46643" ],
  "summary" : "Snappy: Binary path is never shell-escaped due to an inverted is_executable check",
  "details" : "### Impact\n\nOn POSIX, escapeshellarg(‘/usr/bin/wkhtmltopdf’) returns the literal string ‘/usr/bin/wkhtmltopdf’ with the single-quote characters included. is_executable() then looks for a file whose actual name contains those quote characters, which essentially never exists. The safe branch is dead code and $command always falls through to the raw, unescaped value.\n\nThe rest of the arguments (options, input, output) are escaped correctly, so injection has to land in the binary string itself. That happens whenever the binary path is sourced from configuration that is user-influenced, derived from environment variables that ultimately come from request data, or concatenated with any user-controlled fragment.\n\n#### Proof of concept:\n\n```php\n $pdf = new Knp\\Snappy\\Pdf(‘wkhtmltopdf; touch /tmp/snappy_rce’);\n $pdf->generate(‘https://example.com’, ‘/tmp/out.pdf’);\n // /tmp/snappy_rce is created.\n```\n\n**Impact:** command execution as the PHP process when the binary path is attacker-influenced. Even in deployments where the binary is hard-coded, this is a defensive-in-depth regression: downstream packages reasonably assume Snappy shell-escapes the binary because the code looks like it does.\n\n### Patches\n\nThe version 1.7.1 will resolve this security advisory.\n\n### Workarounds\n\nBefore calling the constructor, ensure `\\is_executable($path)` is truthy.\n\n```php\n// Bad example\n$pdf = new Knp\\Snappy\\Pdf('/path/to/binary');\n```\n\n```php\n// Better example\n$pathToBinary = '/path/to/binary';\n\nif (!\\is_executable($pathToBinary)) {\n  throw new \\RuntimeException();\n}\n\n$pdf = new Knp\\Snappy\\Pdf('/path/to/binary');\n```",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "KnpLabs/knp-snappy"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.7.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.7.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/KnpLabs/snappy/security/advisories/GHSA-vpr4-p6fq-85jc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-46643"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/KnpLabs/snappy"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/KnpLabs/snappy/releases/tag/v1.7.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-21T20:22:16Z",
    "nvd_published_at" : "2026-06-10T20:17:28Z"
  }
}