{"answers":{"affected":"2 open source packages ship an affected version, including knplabs/knp-snappy. It affects 1 product.","exploited":"It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-41330 exists.","fix":"Upgrade knplabs/knp-snappy to 1.4.3 or later.","what":"CVE-2023-41330 is a critical unsafe deserialization vulnerability in KnpLabs snappy, published on 6 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for CVE-2023-41330 and fix it if it is affected.\n\nWhat it is: CVE-2023-41330 is a critical unsafe deserialization vulnerability in KnpLabs snappy, published on 6 Sep 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-41330 exists.\n\nAffected packages and fixed versions:\n- knplabs/knp-snappy (Packagist): affected all versions; fixed in 1.4.3\n- knplabs/knp-snappy (Packagist): affected all versions; fixed in 1.4.3\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/CVE-2023-41330/ (Markdown: https://insights.sbomify.com/CVE-2023-41330/index.md)","id":"CVE-2023-41330","markdown":"https://insights.sbomify.com/CVE-2023-41330/index.md","name":"CVE-2023-41330","record":{"aliases":["GHSA-92rv-4j2h-8mjj"],"analysis":{"component_type":"library","fix_type":"upgrade","impacts":["code_execution","data_read"],"network_reachable":"yes","non_default_config":false,"product_category":"PHP Snappy library","requires_auth":"none","summary":"Attacker can achieve remote code execution via PHAR deserialization bypass in KnpLabs Snappy library if they control filename input.","user_interaction":"not_required","vuln_class":"deserialization"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[{"product":"snappy","vendor":"knplabs"}],"cvss":{"score":9.8,"severity":"critical","source":"cna","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","version":"3.1"},"cwes":[{"id":"CWE-502","name":"Deserialization of Untrusted Data"}],"description":"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-\u003egenerate(...)` function.","ecosystems":["Packagist"],"exploits":{"exploitdb":0,"first_seen":null,"github_poc":0,"max_poc_stars":null,"metasploit":0,"nuclei":0,"refs":[],"tier":"weaponised"},"has_fix":true,"headline":"Unsafe deserialization in knplabs/knp-snappy","id":"CVE-2023-41330","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"Packagist","product":null,"products":[],"type":"deserialization","year":"2023"},"n_packages":2,"n_references":3,"next":{"headline":"SOFARPC Remote Command Execution (RCE) Vulnerability","id":"CVE-2023-41331"},"packages":[{"ecosystem":"Packagist","fixed":["1.4.3"],"introduced":["0"],"last_affected":[],"package":"knplabs/knp-snappy","purl":null,"source":"GHSA-92rv-4j2h-8mjj"},{"ecosystem":"Packagist","fixed":["1.4.3"],"introduced":["0"],"last_affected":[],"package":"knplabs/knp-snappy","purl":"pkg:composer/knplabs/knp-snappy","source":"GHSA-92rv-4j2h-8mjj"}],"prev":{"headline":"Domain restrictions bypass via DNS Rebinding in WireMock and WireMock Studio","id":"CVE-2023-41329"},"products":["snappy"],"published":"2023-09-06","related":[{"cvss_score":9.8,"headline":"Snappy vulnerable to PHAR deserialization, allowing remote code execution","id":"CVE-2023-28115","kev_date_added":null,"published":"2023-03-17"}],"sources":[{"class":"attribution","licence":"CVE Terms of Use (MITRE)","name":"CVE List","prefix":"CVE"},{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"attribution","licence":"US public information, NVD API terms","name":"NVD"},{"class":"attribution","licence":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"}],"ssvc":{"automatable":"yes","exploitation":"poc","technical_impact":"total"},"state":"PUBLISHED","updated":"2024-09-30","vendors":["KnpLabs"]},"summary":"Attacker can achieve remote code execution via PHAR deserialization bypass in KnpLabs Snappy library if they control filename input.","url":"https://insights.sbomify.com/CVE-2023-41330/"}