The vulnerability, identified as GHSA-4486-gxhx-5mg7, is a local privilege escalation flaw in PsySH. It stems from the automatic and implicit execution of a .psysh.php configuration file from the Current Working Directory (CWD) upon startup. An attacker could create a malicious .psysh.php file in a shared, writable directory (e.g., /tmp). If a user with elevated privileges subsequently runs PsySH from that directory, the malicious PHP code is executed with those privileges.
The analysis of the security patches (commits 5e93b5c25811b481248623df0527b32120d8b46e and 8ec3d5837c1fb5d537053db2b9713fc716f3e4f2) reveals that the core of the vulnerability was in the Psy\Configuration::init() method. This method was responsible for locating and loading the local configuration file without any trust verification. The fix introduces a "Restricted Mode", which adds a trust verification step. Before loading a local .psysh.php, PsySH now prompts the user for consent or checks against a list of trusted project directories, preventing the automatic execution of untrusted code.
The primary vulnerable function is Psy\Configuration::init(), which contained the unsafe logic. The function Psy\Configuration::loadConfigFile() acts as the execution sink by using require on the provided file path. The process was typically initiated by the Psy\Shell::__construct() constructor, which would create the Configuration object and trigger the vulnerable loading sequence.