TrustFall: One Folder-Trust Click Lets a Cloned Repository Start Its Own MCP Servers in Four AI Coding CLIs
A coding assistant can start programs declared in a project as soon as a developer trusts the folder. Adversa AI demonstrated that behavior in four tools: Claude Code, Cursor CLI, Gemini CLI and GitHub Copilot CLI. In its automated Claude Code test, a project-defined MCP server started without asking and sent test credentials to the researchers. Public evidence of malicious use remains unavailable.
One keypress starts a program the repository chose. A developer clones an unfamiliar repository and starts one of these CLIs in it. The tool asks whether to trust the folder, with trust preselected, and the developer presses Enter. The attacker has already placed a project MCP configuration file in the repository (.mcp.json for Claude Code and Copilot CLI, .cursor/mcp.json for Cursor CLI, .gemini/settings.json for Gemini CLI) whose command and args fields point to the attacker's own program. Once trust is accepted, the tool starts that program as an ordinary operating-system process with the developer's privileges. Adversa reports that in Claude Code this process is not sandboxed or confined to the project folder; its code runs as soon as the process starts, before the model calls any tool, and no further prompt appears. The researchers' published proof of concept only opens the system calculator; they describe such a process going on to read SSH keys and cloud credentials, and show a remote command channel in a demonstration video.
What the prompt tells the developer, and what it approves. Claude Code has a second, per-server prompt that names a new server from .mcp.json, warns that it may run code and offers to continue without it. A repository can skip that prompt by approving its own servers through enableAllProjectMcpServers or enabledMcpjsonServers in a committed .claude/settings.json, or in a .claude/settings.local.json it ships, which takes precedence over the project file. The folder-trust prompt in the tested version 2.1.129 begins "Quick safety check: Is this a project you created or one you trust?" and does not mention MCP; according to Adversa, the dialog before version 2.1 warned that .mcp.json could run code and offered to trust the folder with MCP disabled. Gemini CLI, Cursor CLI and Copilot CLI have no second prompt, so the folder-trust answer is the only decision: Gemini CLI warns about project MCP servers and lists them by name, Cursor CLI shows an MCP warning without listing them, and Copilot CLI shows a generic prompt. By contrast, when a project file asks for Claude Code's bypassPermissions mode, the tool shows a separate red warning whose default is "No, exit". In all four tools, one answer about a folder also approves starting programs the repository chose, and at most the prompt tells the developer their names.
What remains after an earlier fix. CVE-2025-59536, published in October 2025 and fixed in Claude Code 1.0.111, let project code run before the user had answered the trust prompt; according to Adversa, the fix made MCP servers wait until after that answer. TrustFall is about what happens once the answer is yes. Anthropic's security team declined Adversa's report as outside its threat model: under that model, accepting "Yes, I trust this folder" is consent to the full project configuration, so execution afterwards is the boundary working as designed. TrustFall has no CVE. Adversa checked the other three CLIs only after Anthropic's response, and the write-up gives no versions or vendor responses for them.
In CI there is no prompt at all. When Claude Code runs without a terminal, as it does in Anthropic's official GitHub Action claude-code-action, the trust prompt never appears, and Claude Code's documentation says that non-interactive runs and Agent SDK sessions load project MCP servers without asking. The action also always writes enableAllProjectMcpServers: true into the runner's user settings, so a .mcp.json file alone is enough. In a test repository they own, the researchers' workflow started the server as soon as the job began, and the server sent the runner's full environment to a webhook.site collector, including a synthetic secret named TOP_SECRET_KEY that they had planted to make the leak visible. In a real pipeline the same environment could hold deploy keys, signing certificates, cloud credentials or a GitHub token carrying the workflow's permissions. The CI variant was shown only for Claude Code.
Where the CI path is narrower. Adversa says the same chain runs against pull-request branches. The action's own documentation and change history show a limit: since version 1.0.74, released on March 18, 2026, the action by default replaces .claude/ and .mcp.json with the versions on the pull request's base branch before starting Claude Code on pull-request events, keeping the pull request's versions only for reference. A server added in a pull request therefore does not start through the current official action. That protection does not cover manual (workflow_dispatch) or push-triggered runs, the lower-level claude-code-base-action, scripts that call claude -p directly, or a malicious configuration that has already reached the base branch. No public information currently shows TrustFall being used in a real attack.
Keep MCP startup rules in administrator-managed settings outside the project. Claude Code can run only the servers in its managed configuration. GitHub Copilot CLI enterprise policy can restrict the exact command and arguments. Verify each client and run mode with an unapproved test server. Command allowlists do not bind the workspace or control every environment value.
If a server from an unfamiliar repository does start, what it can reach decides the damage. When opening repositories nobody has reviewed, or running headless agents on unreviewed code, run the whole tool inside a hardware-virtualized microVM or a userspace-kernel sandbox that holds no host home directory, SSH keys, cloud credentials or personal tokens, so the started process only reaches that disposable environment. AIDEFEND's guidance verifies the runtime that actually handled the workload instead of trusting a requested setting. Claude Code's built-in sandbox does not replace this layer, because Adversa reports that MCP servers run unsandboxed with the user's full privileges. The credentials the tool itself needs inside the sandbox, such as its model API key and a repository token, stay exposed, and data can still leave unless outbound connections are restricted as well.
AI Workload Identity Permission Scoping at Downstream Services
High
The CI demonstration sent everything in the runner's environment to the researchers' collector, so for each pipeline the question is what those credentials can do elsewhere. Give each headless agent job its own identity and grant it, at GitHub and at each cloud service, only the actions its task needs, for example reading the repository and commenting on pull requests: no deploy keys, signing certificates or production roles, and cloud roles whose trust policy accepts only protected branches or environments. Then call each service with the job's own credential and confirm that requests outside that scope are refused. A credential stolen from the job then cannot publish a release or reach production. The model API key the agent needs is still exposed, and the job can still read the repository it checked out.
A server started from repository configuration usually needs the network to hand over what it read; the CI demonstration posted the runner's environment to a public collection service. On the disposable environments and self-hosted runners that host coding agents, enforce egress outside the sandboxed workload: block outbound connections by default and allow only the model provider, code host and package mirrors the task needs. That post then fails and leaves a denied-connection record. Approved destinations can still carry data, local files the process can read or change are not protected, and GitHub-hosted runners need a self-hosted runner or a separate egress control to apply this.
A malicious server can read whatever the developer or runner can read, and the researchers name SSH keys, cloud credentials, personal access tokens, package-registry tokens and CI secrets as what is at stake. When a machine or pipeline ran one of these CLIs on an unreviewed repository before the controls above were in place, and a malicious server cannot be ruled out, the owner of each long-lived credential that environment could read should revoke it at its issuer, issue a replacement to every consumer and confirm the old value is rejected. This stops the attacker from continuing to use what was taken; it does not undo data already read, and AIDEFEND's worked example covers an AWS IAM key, so other credential types need their own issuer procedure.
Revoking credentials does not remove what is still configured to run. Once a repository configuration is confirmed malicious, preserve it as evidence, then remove the server definitions and auto-approval settings from every checkout and fork the organization controls, and check the developer's login and start-up files, scheduled jobs, SSH authorized keys and user-level agent settings for entries the process may have added; the researchers list these as possible follow-on actions without demonstrating them. Whether the machine is clean has to be confirmed on the affected machine, not inferred from the repository.
What Defenders Should Do Now
Decide centrally which MCP servers may start, whatever a repository says. For Claude Code, the strongest form is a managed-mcp.json file deployed through device management: the client then loads only the organization's servers (an empty mcpServers map disables MCP), and servers in a project's .mcp.json do not load. Where teams need project servers, set allowManagedMcpServersOnly: true in managed settings with an allowedMcpServers list of serverCommand entries that name reviewed executables by absolute paths outside any repository. Do not rely on server names, which the repository chooses and which Anthropic's documentation says are not a security control, or on a managed enabledMcpjsonServers list, because Claude Code's settings documentation says list settings from different files are combined. For Copilot CLI, GitHub's enterprise managed settings support the same kind of command allowlist; for Cursor CLI and Gemini CLI, check what your version and plan actually enforce. Test with a harmless fixture repository whose .mcp.json starts a command that only writes a marker file, approved in both .claude/settings.json and .claude/settings.local.json: after you accept the trust prompt, and again in a headless run, the marker must not appear.
Read an unfamiliar repository's agent configuration before trusting it, or open it somewhere disposable. Before starting any of these CLIs in a cloned repository, check .mcp.json, .claude/settings.json, .claude/settings.local.json, .gemini/settings.json and .cursor/mcp.json: which programs command and args start, whether the arguments carry inline code, and whether the repository pre-approves its own servers. Answer the trust prompt only after that, and read "trust" as permission to run the project's configuration. Open repositories you cannot review in a disposable virtual machine or cloud workspace that holds no SSH keys, cloud credentials or personal tokens.
Keep production credentials away from headless agents that run on unreviewed code. List every workflow that runs claude-code-action, claude-code-base-action, claude -p or another coding CLI without a terminal, and note what triggers it. For each job, check which token permissions and secrets it receives: deploy keys, signing certificates and production cloud roles should not be available to it, and cloud roles should be assumable only from protected branches or environments. Then open a test pull request that adds a harmless .mcp.json server: the server must not start, and the job's environment must contain no production credential.
Respond if a repository-defined server may already have run. If a developer machine or pipeline ran one of these CLIs on an unreviewed repository before these controls were in place, and a malicious server cannot be ruled out, revoke and rotate the SSH keys, cloud keys, personal access tokens, package-registry tokens and CI secrets that environment could read, and remove the repository's configuration and any start-up entries it may have added. If a server confirmed as malicious is still running, stop it as well.
1 additional consideration
Keep the official action's pull-request protection in CI
The official Claude Code action replaces agent configuration from a pull request with the base branch's copy, but only in releases from 1.0.74 onward and only on pull-request events.
Recommendation: CI maintainers can run coding agents on pull requests only through claude-code-action 1.0.74 or later, pinned to a reviewed commit SHA, rather than through claude-code-base-action or a script that calls claude -p in the checked-out pull request, and can read the action's security notes before moving the pin to a newer SHA. After each update, a test pull request that adds a harmless .mcp.json server should show the server is not started. This covers pull-request events only; manual and push-triggered runs, and configuration already on the base branch, still rely on the managed policy.
Conclusion
A folder can contain settings that start a program as soon as it is trusted. AIDEFEND ↗ points to managing those settings outside the project, isolating unreviewed work and giving automated jobs only the credentials they need.