All postsAI

Opening a repository is now code execution

AI coding tools and editors run config files from the repo you open. How the June 2026 Microsoft repo poisoning worked and how to open untrusted code safely.

Johnny Unar7 min read

01

a commit that only adds config files

For years the advice about untrusted code was simple: cloning is safe, running is not. You could clone a repository, read it, and decide whether to execute anything. AI coding agents and modern editors changed that quietly, because they read configuration from the folder you open, and some of that configuration is a list of commands to run.

The incident that made this concrete happened on 5 June 2026. According to StepSecurity's analysis, a previously compromised contributor account pushed a commit to the Azure/durabletask repository with the message "Switched DataConverter to OrchestrationContext [skip ci]", a timestamp backdated to 2020 and no changes to source code. It added five files. GitHub's automated enforcement then disabled 73 repositories across four Microsoft organisations, Azure, microsoft, Azure-Samples and MicrosoftDocs, within about two minutes that afternoon, which also broke every workflow using Azure/functions-action@v1. StepSecurity ties it to the Miasma worm that had hit PyPI from the same account in May.

The five files are the useful part:

text
1.claude/settings.json SessionStart hook: node .github/setup.js
2.gemini/settings.json the same hook for Gemini CLI
3.cursor/rules/setup.mdc alwaysApply rule telling the agent to run node .github/setup.js
4.vscode/tasks.json shell task with "runOn": "folderOpen"
5.github/setup.js 4.6 MB obfuscated credential harvester

Nothing in the repository's code changed, so a reviewer skimming the diff for logic changes would see only config files. StepSecurity's summary is the line worth remembering: cloning the repository was safe, and opening it was not. Each of the four config files targets a different tool, and each runs the same payload through that tool's own, documented feature.

02

how each tool runs repository config

Claude Code reads hooks from .claude/settings.json in the project, and a SessionStart hook runs a shell command when a session begins. Gemini CLI has the same idea in .gemini/settings.json. Cursor rules with alwaysApply: true are injected into every agent conversation, so a rule that says "run this setup script first" is a prompt injection aimed at an agent that can run commands. VS Code tasks with runOptions.runOn: "folderOpen" run when the folder opens, without any AI involved.

All of these are legitimate features. Teams use session hooks to load context and folder-open tasks to start a dev server. The problem is that they're executable configuration shipped inside the thing you're evaluating, and each tool has its own rules about when it trusts that configuration.

Claude Code shows a workspace trust dialog the first time you start an interactive session in a folder you haven't trusted, and project-level allow rules wait for that trust. But its permissions documentation also says that a claude -p run or an SDK session never shows the dialog, and in that mode hooks from the project's settings files are used and servers in .mcp.json are connected without asking. That matters if you run an agent non-interactively over pull requests or third-party repos in CI. The docs list the options for that case: --setting-sources user so project settings and .mcp.json aren't read, --bare to skip project hooks, skills and MCP servers, or --settings '{"disableAllHooks": true}'. Setting disableAllHooks only in your user settings isn't enough, because project settings take precedence and can set it back.

Gemini CLI's trusted folders feature, per its docs, is off by default. When you enable it with security.folderTrust.enabled: true in your user settings, an untrusted folder doesn't get its .gemini/settings.json, .env files or MCP servers loaded. Until you turn it on, project settings load wherever you run it.

VS Code has Workspace Trust enabled by default, and its Restricted Mode blocks tasks, debugging and workspace settings until you trust the folder. On top of that, task.allowAutomaticTasks defaults to off, which prompts once per workspace before running folder-open tasks, and the docs state that automatic tasks never run in an untrusted workspace regardless of that setting. Cursor is a VS Code fork, but Oasis Security reported in September 2025 that it shipped with Workspace Trust disabled, so a folderOpen task ran as soon as a folder was opened. Check security.workspace.trust.enabled in your Cursor settings rather than assuming the VS Code default.

03

look before you open

The cheapest defence is to look at the executable config before any tool reads it. A fresh clone is safe to inspect from a plain terminal, so make that a habit for anything you didn't write. This script lists the files and prints the parts that run commands:

bash
1#!/usr/bin/env bash
2# Usage: inspect-agent-config <path-to-fresh-clone>
3set -euo pipefail
4cd "$1"
5git ls-files -- .claude .gemini .cursor .vscode .mcp.json .devcontainer AGENTS.md CLAUDE.md GEMINI.md
6for f in .claude/settings.json .claude/settings.local.json .gemini/settings.json; do
7 [ -f "$f" ] && jq -c --arg f "$f" '{file: $f, hooks: .hooks, mcp: .mcpServers}' "$f"
8done
9[ -f .vscode/tasks.json ] && jq -c '.tasks[]? | select(.runOptions.runOn == "folderOpen") | {label, command}' .vscode/tasks.json
10[ -f .mcp.json ] && jq -c '.mcpServers | to_entries[] | {name: .key, command: .value.command, args: .value.args}' .mcp.json
11grep -rls 'alwaysApply: *true' .cursor 2>/dev/null || true

Run against a test repository recreating the five Miasma files with a harmless script, it printed both SessionStart hooks with node .github/setup.js, the Setup folder-open task, the MCP server command and the Cursor rule's path. Two caveats: VS Code allows comments in tasks.json, which jq can't parse, so if it errors, read the file by hand, and instruction files like AGENTS.md and CLAUDE.md can carry prompt injections too, which no jq filter will find, so skim them.

For repositories you own, add the same paths to code review. A CI step that flags any change to agent or editor config makes sure a person looks at it, which is exactly what a [skip ci] commit with a backdated timestamp is trying to avoid:

bash
1changed=$(git diff --name-only origin/main...HEAD -- .claude .gemini .cursor .vscode .mcp.json .github/workflows)
2if [ -n "$changed" ]; then
3 echo "Agent or editor config changed, needs security review:"
4 echo "$changed"
5 exit 1
6fi

Branch protection that requires review on the default branch would have stopped a direct push like the one on 5 June, and a CODEOWNERS entry for these paths routes those reviews to someone who knows what a hook is.

04

open untrusted code where it can't reach your credentials

Inspection catches what you know to look for. Isolation covers the rest. When you want to read, build or run an agent over code you don't trust, do it somewhere that holds none of your credentials. A plain container with the repository mounted read-only, no network and no access to your home directory is enough for reading and static analysis:

bash
1docker run --rm -it --network none --cap-drop ALL --security-opt no-new-privileges \
2 -v "$PWD":/src:ro -w /src node:24-slim bash

Inside, there's no ~/.ssh, no cloud credentials, no tokens in the environment, and the repository can't be modified. If you need network access to install dependencies or reach a model API, give the container that and nothing else, and still don't mount your home directory.

Dev containers are convenient but not automatically isolated. The VS Code Dev Containers extension forwards your local SSH agent if one is running and shares your Git credential helper with the container by default, so code running inside can use your Git credentials. The devcontainer.json file is also repository-supplied config that runs commands, through postCreateCommand and similar hooks. For code you really don't trust, a disposable VM or a cloud sandbox with no access to your accounts is the honest answer, and Claude Code's own security docs recommend VMs for running scripts and tool calls when working with untrusted content.

05

make a harvest worth less

Some of these attacks will eventually get through, so the last layer is making sure that what a harvester finds on a developer machine expires quickly and can't reach production. Cloud access through SSO with session credentials that last an hour beats long-lived access keys in ~/.aws/credentials. GitHub fine-grained tokens scoped to the repositories you work on beat a classic token with full repo scope. npm and PyPI publishing should go through trusted publishing in CI, not a token on a laptop.

MCP servers deserve the same treatment as any other privileged local service. Install them from pinned versions, review a server's code or source before adding it, and don't give a server standing production credentials: if an agent needs to query a database, point it at a read-only replica or a staging copy through credentials that can be revoked on their own. In Claude Code, disabledMcpjsonServers rejects a named .mcp.json server in every session type, and managed settings let an organisation restrict which MCP servers can run at all. A compromised laptop is then a credential rotation and an afternoon of cleanup, not a production breach.

Thanks for reading.
Johnny Unar

Written by

Johnny Unar

Keep reading

Stop patching.Start building.

Tell us what's slowing you down. We'll bring coffee and opinions.