The vulnerability, GHSA-mqxh-6gq7-558m, exists because Pi Agent versions prior to 0.79.0 would automatically load and process configuration and executable extensions from a project's .pi directory without user consent. An attacker could craft a malicious repository, and when a user runs pi within that repository, the agent would execute the attacker's code with the user's permissions.
The root cause is the lack of a trust boundary for project-local resources. The startup sequence would discover and load all resources from both user-level and project-level directories indiscriminately.
The patch introduces a "project trust" mechanism. Now, when pi starts in a directory containing project-local resources, it checks for a saved trust decision. If none exists, it prompts the interactive user for approval before loading any project-specific files. The core of the fix lies in modifying the resource and settings loaders to be aware of this trust state.
The identified vulnerable functions are key components of this unsafe loading process:
SettingsManager.fromStorage: Unconditionally loaded project settings (.pi/settings.json), which could be crafted to enable malicious extensions.
DefaultPackageManager.resolve: Unconditionally discovered resource paths, including executable extensions, from the untrusted project directory.
DefaultResourceLoader.reload: Orchestrated the loading process, taking the untrusted paths and executing the extension code.
loadProjectContextFiles: Loaded instructional files from the project, which, while less severe than code execution, was part of the same trust-violating behavior.
By exploiting this chain, an attacker could achieve arbitrary code execution on a victim's machine by tricking them into running pi in a malicious repository.