{"answers":{"affected":"4 open source packages ship an affected version, including typo3/phar-stream-wrapper.","exploited":"There is no known exploitation of GHSA-4v5g-8pq2-32m2 in the wild and no public exploit code.","fix":"Upgrade typo3/phar-stream-wrapper to a fixed version for your release line: 2.0.1 or 3.0.1.","what":"GHSA-4v5g-8pq2-32m2 is an unsafe deserialization vulnerability in typo3/phar-stream-wrapper, published on 5 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-4v5g-8pq2-32m2 and fix it if it is affected.\n\nWhat it is: GHSA-4v5g-8pq2-32m2 is an unsafe deserialization vulnerability in typo3/phar-stream-wrapper, published on 5 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-4v5g-8pq2-32m2 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- typo3/phar-stream-wrapper (Packagist): affected from 1.0.0; fixed in 2.0.1\n- typo3/phar-stream-wrapper (Packagist): affected from 1.0.0; fixed in 2.0.1\n- typo3/phar-stream-wrapper (Packagist): affected from 3.0.0; fixed in 3.0.1\n- typo3/phar-stream-wrapper (Packagist): affected from 3.0.0; fixed in 3.0.1\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/GHSA-4v5g-8pq2-32m2/ (Markdown: https://insights.sbomify.com/GHSA-4v5g-8pq2-32m2/index.md)","id":"GHSA-4v5g-8pq2-32m2","markdown":"https://insights.sbomify.com/GHSA-4v5g-8pq2-32m2/index.md","name":"GHSA-4v5g-8pq2-32m2","record":{"aliases":[],"analysis":{"component_type":"library","fix_type":"patch","impacts":["code_execution"],"network_reachable":"yes","non_default_config":false,"product_category":"PHP PharStreamWrapper library","requires_auth":"none","summary":"Attackers can bypass PharStreamWrapper protections via exception handling flaws, enabling insecure deserialization and remote code execution in PHP applications.","user_interaction":"not_required","vuln_class":"deserialization"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"Insecure deserialization is a vulnerability which occurs when untrusted data is used to abuse the logic of an application. In July 2018, the vulnerability of insecure deserialization when executing Phar archives was addressed by removing the known attack vector in the TYPO3 core. For more details read the corresponding TYPO3 advisory.\n\nIn addition, a new interceptor was introduced to protect possible (but unknown) vulnerabilities in 3rd party components like TYPO3 extensions. Basically, the PharStreamWrapper intercepts direct invocations of Phar archives and allows or denies further processing based on individual rules.\n\nRecently, the PharStreamWrapper was extracted from the TYPO3 core and released as standalone package under the MIT license. It is now available for any PHP driven project.\n\nThe stream wrapper overwrites the existing Phar handling of PHP, applies its own assertions and then restores the native PHP Phar handling for the corresponding commands (e.g. file_exists, include, fopen) to continue processing. After that, the native PHP Phar handling gets disabled and is overwritten by the logic of the PharStreamWrapper again. This is the only way to control invocations of Phar archives as PHP only allows a single handler for each corresponding stream.\n\nWe were informed that exception and error handlers in custom applications (e.g. TYPO3 extensions) sometimes didn't return to the original operating sequence of the PharStreamWrapper. A possible consequence was that the unprotected native PHP Phar handling remained active and therefore became vulnerable for the basic issue of insecure deserialization again.\n\nExamples\nTake a look at the following examples showing how the handling is by-passed in custom application code.\n\nScenario A: Exception thrown from code organized in a Phar archive\n```\ntry {\n    include('phar://path-to-archive/good-archive.phar');\n} catch (\\Throwable $throwable) {\n    // not doing much here, continue execution\n}\n// the insecure value can be anything that is or was user-submitted\n// and cannot be trusted in terms of security, $_GET is just used as example\n$insecureValue = $_GET['path'];\n// the value might be 'phar://path-to-archive/malicious-archive.phar'\nfile_exists($insecureValue);\n```\nScenario B: Errors converted to exceptions and thrown when interacting with archive contents\n```\n// set error handler in order to convert errors to exceptions\nset_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {\n   throw new ErrorException($errstr, 0, $errno, $errfile, $errline);\n});\n// interacting with Phar archive\ntry {\n   $resource = opendir('phar://path-to-archive/good-archive.phar/non-existing-path/');\n   closedir($resource);\n} catch (\\Throwable $throwable) {\n   // not doing much here, continue execution\n}\n// the insecure value can be anything that is or was user-submitted\n// and cannot be trusted in terms of security, $_GET is just used as example\n$insecureValue = $_GET['path'];\n// the value might be 'phar://path-to-archive/malicious-archive.phar'\nfile_exists($insecureValue);\n```","ecosystems":["Packagist"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"By-passing Protection of PharStreamWrapper Interceptor","id":"GHSA-4v5g-8pq2-32m2","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"Packagist","product":null,"products":[],"type":"deserialization","year":"2024"},"n_packages":4,"n_references":null,"packages":[{"ecosystem":"Packagist","fixed":["2.0.1"],"introduced":["1.0.0"],"last_affected":[],"package":"typo3/phar-stream-wrapper","purl":null,"source":"GHSA-4v5g-8pq2-32m2"},{"ecosystem":"Packagist","fixed":["2.0.1"],"introduced":["1.0.0"],"last_affected":[],"package":"typo3/phar-stream-wrapper","purl":"pkg:composer/typo3/phar-stream-wrapper","source":"GHSA-4v5g-8pq2-32m2"},{"ecosystem":"Packagist","fixed":["3.0.1"],"introduced":["3.0.0"],"last_affected":[],"package":"typo3/phar-stream-wrapper","purl":null,"source":"GHSA-4v5g-8pq2-32m2"},{"ecosystem":"Packagist","fixed":["3.0.1"],"introduced":["3.0.0"],"last_affected":[],"package":"typo3/phar-stream-wrapper","purl":"pkg:composer/typo3/phar-stream-wrapper","source":"GHSA-4v5g-8pq2-32m2"}],"products":null,"published":"2024-06-05","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Attackers can bypass PharStreamWrapper protections via exception handling flaws, enabling insecure deserialization and remote code execution in PHP applications.","url":"https://insights.sbomify.com/GHSA-4v5g-8pq2-32m2/"}