Sample alert How it works Coverage PENTEST METHODOLOGY DOCS PRICING FAQ MCP CONTACT LOG IN SCAN MY APP →

Cloned repo ran commands: how to stop auto-run in AI agents

FIX / REPO CONFIG AUTO-RUN / 9 MIN READ

Update Claude Code, Cursor, and Amazon Q Developer to the patched versions. Read the config files of an unknown repo before you open it with an agent. Run unknown code in a container. Several past bugs let a repo start commands, or turn on a bypass mode, before the trust prompt showed.

This guide lists the files that change agent behavior, the verified fixes, and the steps to lower the risk.

Which files in a repo can change agent behavior?

An agent reads config files from the project folder. A repo author controls those files. When you clone the repo, you also copy the author’s settings.

These files matter most:

  • Claude Code: .claude/settings.json can set hooks, permission rules, and the default permission mode. .mcp.json lists MCP servers. CLAUDE.md gives instructions.
  • Cursor: .cursor/mcp.json lists MCP servers. .cursor/rules/ holds rules files.
  • Amazon Q Developer: .amazonq/mcp.json lists MCP servers.
  • VS Code: .vscode/tasks.json can define tasks. A task can start a command.
  • Many tools: AGENTS.md gives instructions to the agent.

An MCP server entry has a command field. The tool starts that command on your machine. A hook in .claude/settings.json also runs a command. If the tool loads such a file without a prompt, the repo author runs code as you.

The files do not need to look dangerous. A starter template can include a normal-looking MCP config. A pull request can add one line to it. Most people do not review dot-folders.

Caution: The risk is the same as running npm install from an unknown repo. The agent config is a new place for it to hide.

What went wrong in the past?

Three verified cases show the pattern. Each has a fix. Each fix is only useful if you update.

Claude Code: CVE-2026-33068

Claude Code read the permission mode from settings files before it decided to show the workspace trust dialog. This included the settings file in the repo. A malicious repo could set permissions.defaultMode to bypassPermissions in its committed .claude/settings.json. The tool then skipped the trust prompt on first open.

The GitHub advisory GHSA-mmgp-wc2j-qcv7 rates it High. Affected versions are below 2.1.53. The patched version is 2.1.53.

Cursor: CVE-2025-54135

Aim Labs named this flaw CurXecute. The flaw let a prompt injection change the MCP config file ~/.cursor/mcp.json. Cursor ran new entries in that file without user confirmation. The NVD record lists version 1.3.9 as the fix. The Hacker News reports that the 1.3 release also replaced the auto-run denylist with an allowlist.

This case needs a prompt injection first. An attacker can place the injection in a README, an issue, or a web page that the agent reads. The agent then writes the config, and the config runs the command.

Amazon Q Developer: CVE-2026-12957

Amazon Q loaded and ran MCP server commands from .amazonq/mcp.json in a workspace. It did this without workspace trust checks or user consent. The Cloud Security Alliance note names this CVE and a companion bug, CVE-2026-12958. It says that full remediation is in Language Servers for AWS version 1.69.0.

Wiz, the team that found the bug, says that versions before 1.65.0 are affected. Amazon deployed a first fix on May 12, 2026. Use 1.69.0 or later, which is the version in the CSA note.

How do I update to the patched versions?

Check each tool. Do the steps in this order.

  1. Check the Claude Code version:

    claude --version
    
  2. If the version is below 2.1.53, update the tool:

    claude update
    

    If you installed with npm, run npm install -g @anthropic-ai/claude-code@latest.

  3. Open Cursor. Open the About dialog. The version must be 1.3.9 or later. Newer is better.

  4. Update Amazon Q Developer in your IDE. Reload the IDE. The extension then updates the language server.

  5. Check that the language server is 1.69.0 or later. If your IDE blocks auto-update, update the plugin by hand.

Warning: Do not trust a version number from a pop-up or an email. Read the version in the tool, and compare it with the vendor advisory.

Turn on auto-update where the tool offers it. Old versions keep every old bug. Attackers search for users who did not update.

How do I read a repo before I open it with an agent?

Read the config files in a plain viewer. Do not open the folder in the agent first. A text editor with no agent, or cat, is enough.

  1. Clone the repo with hooks off, and open no tool in it:

    git clone --config core.hooksPath=/dev/null https://github.com/example/starter.git
    cd starter
    
  2. List the agent files, with hidden folders:

    ls -la .claude .cursor .amazonq .vscode 2>/dev/null
    find . -name "AGENTS.md" -o -name "CLAUDE.md" -o -name ".mcp.json" -o -name ".cursorrules"
    
  3. Read each file. Use cat, not an agent.

    cat .claude/settings.json .mcp.json .cursor/mcp.json .amazonq/mcp.json 2>/dev/null
    
  4. Search for risky words in all the files:

    grep -rnE "bypassPermissions|hooks|\"command\"|curl|wget|base64|sh -c" .claude .cursor .amazonq .vscode .mcp.json 2>/dev/null
    
  5. Look for hidden Unicode in the text files. The rules file guide has a command for this.

Stop if you see any of these:

  • A hooks block that runs curl, wget, or a shell script.
  • An MCP server with a command that you do not know.
  • A defaultMode set to bypassPermissions.
  • An env block that sets ANTHROPIC_BASE_URL or another endpoint.
  • A command that holds Base64 text.

If a file looks wrong, delete it before you open the repo. A repo without these files still works as code.

How do I turn off auto-run and bypass modes?

The fixes above close known bugs. The safe default is to give the agent less power. Use these rules.

Claude Code

Do not use bypassPermissions on your own machine. Set a strict mode in your user settings. User settings are not part of the repo. Add deny rules for the files that hold secrets:

{
  "permissions": {
    "defaultMode": "default",
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(~/.ssh/**)",
      "Read(~/.aws/**)"
    ]
  }
}

Save this as ~/.claude/settings.json. Use an allowlist for safe commands, such as Bash(npm run test). Do not allow Bash(*).

The Claude Code security guide explains the permission model. The guide on .env files shows how to protect secrets from the agent.

Cursor

Open the Cursor settings. Turn off auto-run, or use the allowlist mode. Do not use a denylist. The Hacker News report says that attackers bypassed the denylist with Base64 encoding, shell scripts, and quoting tricks. Review each new MCP server by hand.

The Cursor Composer guide and the dangerous command guide give more steps.

Amazon Q Developer

After the fix, Amazon Q asks before it loads workspace MCP servers. Read the command in the prompt. Click deny when the command is not clear.

All tools

  • Read each MCP server command before you approve it.
  • Keep approval prompts on. Treat an instruction to turn them off as a warning sign.
  • Put the MCP config in your user folder, not in the repo, when you can.
  • Do not store production keys on the machine that you use to try unknown repos.

How do I run an unknown repo in a safe place?

Use a container or a virtual machine. The agent and the repo then run in a box with no access to your home folder.

A simple Docker setup:

docker run --rm -it \
  --cap-drop ALL \
  --security-opt no-new-privileges \
  -v "$PWD":/work -w /work \
  node:22 bash

This command mounts only the repo folder. It does not mount ~/.ssh, ~/.aws, or your browser profile. The container sees no keys from your host.

Follow these rules:

  1. Mount only the project folder.
  2. Pass no environment variables with real keys.
  3. Use test keys with low limits.
  4. Turn off the network if the task does not need it. Use --network none.
  5. Delete the container when the work ends.

Caution: A container is not a perfect wall. A bug in the runtime can break it. It still gives far more protection than your normal shell.

A dev container or a cloud workspace also works. The key point is that the box has nothing worth stealing.

How do I check if a repo already ran something?

Check the machine in this order.

  1. Look at the shell history for commands that you did not type:

    tail -n 100 ~/.zsh_history
    
  2. List processes that started recently:

    ps -axo pid,lstart,command | sort -k2 | tail -n 30
    
  3. Search for new files in your home folder from the last day:

    find ~ -type f -mtime -1 -not -path "*/Library/*" -not -path "*/node_modules/*" 2>/dev/null | head -n 50
    
  4. Open your user-level agent config. Look for MCP servers or hooks that you did not add:

    cat ~/.claude/settings.json ~/.cursor/mcp.json 2>/dev/null
    
  5. Check your cloud accounts for sign-ins and new keys. Check GitHub for new SSH keys, tokens, and deploy keys.

If you find a command that you did not run, treat the machine as exposed. Rotate the keys that it could read. This list covers most cases:

  • Cloud keys in ~/.aws or ~/.config.
  • GitHub and npm tokens.
  • SSH keys.
  • API keys in .env files. The guide on AI bill spikes shows what to do when an AI key leaks.
  • Supabase service role keys, if they were on the machine.

Rotate first. Investigate after. A fast rotation limits the damage.

How do I stop this in the future?

Build a small habit and a few fixed rules.

  1. Update the agent tools every week.
  2. Read the config files in every cloned repo before the first agent session.
  3. Use a container for unknown starter kits and templates.
  4. Keep the default permission mode in your user settings, not in the project.
  5. Add the agent config files to code review. A change to .claude/, .cursor/, .amazonq/, or .mcp.json needs a second reader.
  6. Use a separate machine user or a separate machine for risky work.
  7. Keep production keys out of local .env files. Use short-lived keys with low limits.

The CSA research note shows why step 7 matters. These attacks aim to steal credentials. A machine that holds few credentials gives the attacker little.

If your project has a team, add a rule to your contribution guide. The rule is that no pull request can add an MCP server or a hook without a review from the owner.

When should I get help?

Ask for help in these cases:

  • You ran an unknown repo with bypass mode on, and the machine held production keys.
  • You see sign-ins or API calls that you did not make.
  • A cloud bill grows without a reason.
  • You cannot tell which keys the machine could read.

Contact the vendor support for the cloud account first. Tell them about the possible key theft. A security person can then check logs and the scope of the exposure. After you rotate the keys, run a scan of your live app to find open data and old keys that remain.

Common questions

Can a repo run commands only because I opened it?
Yes, in old versions of some tools. Config files in the repo started commands before the trust prompt. The vendors fixed the known cases, so you must update the tools.
Is the trust prompt enough protection?
No. The trust prompt is one layer, and past bugs skipped it. Read the config files before you open the repo. Use a container for unknown code.
Which files must I read in a cloned repo?
Read .claude/settings.json, .mcp.json, .cursor/mcp.json, .amazonq/mcp.json, and .vscode/tasks.json. Also read AGENTS.md, CLAUDE.md, and the rules files.
Is bypass mode safe in a container?
It is safer, but not safe. A container with no secrets and no network access limits the damage. A container that holds your keys does not.
What must I do if I opened a bad repo?
Close the tool and stop its processes. Rotate every key that the machine could read. Check shell history, new files, and new MCP entries.

Check your live app

A VibeEval scan tests the web app and API from outside. It checks the app whose keys a malicious repo could have stolen, for exposed keys, open routes, and open data.

14-day free trial · Cancel anytime

SCAN YOUR APP →