GHSA-VPR4-P6FQ-85JC

Vulnerability from github – Published: 2026-05-21 20:22 – Updated: 2026-05-21 20:22
VLAI
Summary
Snappy: Binary path is never shell-escaped due to an inverted is_executable check
Details

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:

 $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.

// Bad example
$pdf = new Knp\Snappy\Pdf('/path/to/binary');
// Better example
$pathToBinary = '/path/to/binary';

if (!\is_executable($pathToBinary)) {
  throw new \RuntimeException();
}

$pdf = new Knp\Snappy\Pdf('/path/to/binary');
Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 1.7.0"
      },
      "package": {
        "ecosystem": "Packagist",
        "name": "KnpLabs/knp-snappy"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "1.7.1"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-46643"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-05-21T20:22:16Z",
    "nvd_published_at": null,
    "severity": "HIGH"
  },
  "details": "### Impact\n\nOn POSIX, escapeshellarg(\u2018/usr/bin/wkhtmltopdf\u2019) returns the literal string \u2018/usr/bin/wkhtmltopdf\u2019 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(\u2018wkhtmltopdf; touch /tmp/snappy_rce\u2019);\n $pdf-\u003egenerate(\u2018https://example.com\u2019, \u2018/tmp/out.pdf\u2019);\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(\u0027/path/to/binary\u0027);\n```\n\n```php\n// Better example\n$pathToBinary = \u0027/path/to/binary\u0027;\n\nif (!\\is_executable($pathToBinary)) {\n  throw new \\RuntimeException();\n}\n\n$pdf = new Knp\\Snappy\\Pdf(\u0027/path/to/binary\u0027);\n```",
  "id": "GHSA-vpr4-p6fq-85jc",
  "modified": "2026-05-21T20:22:16Z",
  "published": "2026-05-21T20:22:16Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/KnpLabs/snappy/security/advisories/GHSA-vpr4-p6fq-85jc"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/KnpLabs/snappy"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "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",
      "type": "CVSS_V4"
    }
  ],
  "summary": "Snappy: Binary path is never shell-escaped due to an inverted is_executable check"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.

Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…