{"id":"CVE-2023-41330","published":"2023-09-06T17:33:21Z","modified":"2024-09-30T15:54:18Z","title":"Unsafe deserialization in knplabs/knp-snappy","vendor":"KnpLabs","product":"snappy","tier":"tail","description":{"text":"knplabs/knp-snappy is a PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page.\n## Issue\n\nOn March 17th the vulnerability CVE-2023-28115 was disclosed, allowing an attacker to gain remote code execution through PHAR deserialization. Version 1.4.2 added a check `if (\\strpos($filename, 'phar://') === 0)` in the `prepareOutput` function to resolve this CVE, however if the user is able to control the second parameter of the `generateFromHtml()` function of Snappy, it will then be passed as the `$filename` parameter in the `prepareOutput()` function. In the original vulnerability, a file name with a `phar://` wrapper could be sent to the `fileExists()` function, equivalent to the `file_exists()` PHP function. This allowed users to trigger a deserialization on arbitrary PHAR files. To fix this issue, the string is now passed to the `strpos()` function and if it starts with `phar://`, an exception is raised. However, PHP wrappers being case insensitive, this patch can be bypassed using `PHAR://` instead of `phar://`. A successful exploitation of this vulnerability allows executing arbitrary code and accessing the underlying filesystem. The attacker must be able to upload a file and the server must be running a PHP version prior to 8. This issue has been addressed in commit `d3b742d61a` which has been included in version 1.4.3. Users are advised to upgrade. Users unable to upgrade should ensure that only trusted users may submit data to the `AbstractGenerator->generate(...)` function.\n","provenance":"source","from":"CVE.org"},"cvss":{"score":9.8,"severity":"CRITICAL","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.02287,"percentile":0.83167,"provenance":"source"},"cwes":[{"id":"CWE-502","name":"Deserialization of Untrusted Data"}],"references":[{"url":"https://github.com/KnpLabs/snappy/security/advisories/GHSA-92rv-4j2h-8mjj","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/KnpLabs/snappy/security/advisories/GHSA-gq6w-q6wh-jggc","tags":["x_refsource_MISC"]},{"url":"https://github.com/KnpLabs/snappy/commit/d3b742d61a68bf93866032c2c0a7f1486128b67e","tags":["x_refsource_MISC"]}],"priority":{"score":23.5,"factors":[{"name":"EPSS percentile","points":16.63},{"name":"CVSS severity","points":6.86}]},"vendorSlug":"knplabs","affectedVersions":[{"vendor":"KnpLabs","product":"snappy","versions":["< 1.4.3"]}],"affected":[{"ecosystem":"Packagist","package":"knplabs/knp-snappy","vulnerableRanges":["<1.4.3"],"patched":["1.4.3"],"from":["GHSA-92rv-4j2h-8mjj"],"provenance":"source"}],"euvd":{"id":"EUVD-2023-2470","exploited":false,"provenance":"source"},"lineage":{"familyId":"fam-knplabs-snappy-cve-2023-28115","parents":[{"from":"CVE-2023-28115","to":"CVE-2023-41330","relation":"successor","confidence":"high","kind":"lineage","evidence":[{"kind":"osv-related","provenance":"source","id":"GHSA-gq6w-q6wh-jggc","via":"related"},{"kind":"osv-related","provenance":"source","id":"GHSA-92rv-4j2h-8mjj","via":"reference","url":"https://github.com/KnpLabs/snappy/security/advisories/GHSA-gq6w-q6wh-jggc"},{"kind":"version-step","provenance":"source","package":"Packagist:knplabs/knp-snappy","fromFixed":"1.4.2","toFixed":"1.4.3","daysApart":173},{"kind":"same-code","provenance":"machine","files":["src/Knp/Snappy/AbstractGenerator.php"],"commits":["https://github.com/KnpLabs/snappy/commit/1ee6360cbdbea5d09705909a150df7963a88efd6","https://github.com/KnpLabs/snappy/commit/b66f79334421c26d9c244427963fa2d92980b5d3","https://github.com/KnpLabs/snappy/commit/d3b742d61a68bf93866032c2c0a7f1486128b67e"],"basis":"shared function","functions":["executeCommand"]},{"kind":"similar","provenance":"machine","score":0.38,"basis":"same product + CWE + description similarity"}]}],"children":[{"from":"CVE-2023-41330","to":"CVE-2026-49286","relation":"related","confidence":"high","kind":"lineage","evidence":[{"kind":"osv-related","provenance":"source","id":"GHSA-92rv-4j2h-8mjj","via":"related"},{"kind":"osv-related","provenance":"source","id":"GHSA-2fmj-p74r-3wjm","via":"reference","url":"https://github.com/KnpLabs/snappy/security/advisories/GHSA-92rv-4j2h-8mjj"}]}],"packageHistory":[{"cve":"CVE-2023-28115","published":"2023-03-17","fixed":"1.4.2","kev":false},{"cve":"CVE-2023-41330","published":"2023-09-06","fixed":"1.4.3","kev":false},{"cve":"CVE-2026-46683","published":"2026-06-10","fixed":"1.7.0","kev":false}],"package":"Packagist:knplabs/knp-snappy"}}