The vulnerability is a classic Server-Side Request Forgery (SSRF) and Local File Inclusion (LFI) found in the knplabs/knp-snappy library. The root cause is located in the Knp\Snappy\Pdf::isOptionUrl method. The original implementation used PHP's filter_var function with the FILTER_VALIDATE_URL flag to check if an option value was a URL. This filter is notoriously permissive and validates URLs with schemes like file://, which an attacker can abuse.
The exploit is triggered when a developer uses the Knp\Snappy\Pdf::generate method and passes untrusted user input into the $options array, specifically for the xsl-style-sheet key. An attacker could provide a payload like file:///etc/passwd.
During the PDF generation process, the generate method (from the parent AbstractGenerator class) processes the provided options. It calls the isOptionUrl method to determine how to handle the option value. The vulnerable version of isOptionUrl would incorrectly validate the file:// path as a valid URL, causing the underlying wkhtmltopdf binary to read the local file and embed its content, or make requests to internal network resources.
The patch addresses this by completely replacing the logic in isOptionUrl. The new implementation parses the URL and explicitly checks its scheme against a configurable allowlist, which defaults to only http and https. The Knp\Snappy\Pdf constructor was also updated to allow developers to customize this list of allowed schemes if needed.