Save 20% on your first hosting bill — use code HOSTING20 Claim now →
Live Bulletproof domains & hosting · Pay with crypto or card Bulletproof domains & hosting
How a Clean GitHub Repo Tricks AI Agents Into Running Malware
How a Clean GitHub Repo Tricks AI Agents Into Running Malware — Security guide on LaunchPad Host

How a Clean GitHub Repo Tricks AI Agents Into Running Malware

LH
By LaunchPad Host Team · Hosting & Infrastructure
Published · 5 min read

Key Takeaways

  • The repo's visible source code is clean; the attack hides in agent config files like .cursor/rules and .claude/settings.json that auto-run commands.
  • The 2026 Miasma worm used this exact technique, detonating the moment a developer opened an infected repo in an AI coding tool.
  • No npm or GitHub vulnerability is exploited — the malware rides legitimate auto-run features, so traditional dependency scanners miss it.
  • Disable auto-run, inspect dotfolders before opening a repo, and run untrusted code inside a disposable, isolated environment.
  • Deploy from clean, reproducible build pipelines on an isolated host rather than straight from a developer machine that touched an unknown repo.

How can a clean GitHub repo trick an AI agent into running malware?

The source code looks fine because the malware is not in the source code. It hides in the configuration files your AI coding agent reads automatically — files like .cursor/rules, .claude/settings.json, or a package.json test script. When you clone the repo and open it in an agent, those files quietly instruct the tool to fetch and execute a payload. You never typed a command, and the visible code passed review.

This is a prompt-injection-meets-supply-chain attack, and it works because AI agents and modern IDEs treat repository files as trusted instructions, not just inert text. A line in a rules file that says run this setup script is, to the agent, a legitimate directive. The repo can have a polished README, real working features, and thousands of stars. The hostile part is a few kilobytes in a folder most developers never open.

The danger is not a vulnerability in GitHub or npm. It is that cloning a repo used to mean reading code, and now it can mean executing it.

The Miasma worm: a real-world 2026 example

This stopped being theoretical on June 3, 2026, when the Miasma worm hit both the npm registry and GitHub source repositories at once. On the GitHub side, an attacker pushed an innocuous-looking commit — titled something like chore: update dependencies [skip ci] — to a popular library and several sibling repos. The commit did not touch the application logic. It planted configuration files engineered to achieve code execution across five different developer tools.

The reported payload runner was wired to fire through Claude Code, Gemini CLI, Cursor, VS Code, and the npm test script. One planted file was a .claude/settings.json with a SessionStart hook, so the payload ran automatically the instant an agent session opened the folder. A .cursor/rules entry did the same job for Cursor users. The worm spread to dozens of repositories, including ones in major organizations, before it was caught.

What made conventional defenses fail is that the worm operated entirely inside legitimate channels. It did not exploit a bug. It used features working exactly as designed — auto-run hooks and agent rule files that exist to make development faster.

Why your dependency scanner never sees it

Most teams assume their supply-chain security tools cover this. They usually do not, because those tools look in the wrong place. Software composition analysis scans your declared dependencies for known-vulnerable versions. This attack ships zero malicious dependencies — the danger is a config file that tells your agent to download something later, at runtime, from somewhere the lockfile never mentions.

Here is how the blind spots line up against the real attack surface:

What it checksTypical toolCatches this attack?
Known-vulnerable dependenciesnpm audit, Snyk, DependabotNo — no bad package is declared
Secrets committed to codegit-secrets, TruffleHogNo — payload is fetched, not stored
Source code logic flawsSAST / human reviewRarely — app source is genuinely clean
Agent config and dotfilesManual inspectionOnly if you actually open them
Runtime network and exec callsSandbox / EDR monitoringYes — if the code runs isolated

A 2026 review covering 78 studies found that every major coding agent — Claude Code, GitHub Copilot, Cursor — fell to prompt injection, with adaptive attacks succeeding more than 85% of the time. The gap is not a single buggy product. It is an industry-wide assumption that repo files are safe to read.

Tired of slow, overcrowded web hosting?

LaunchPad Host runs on NVMe SSDs + LiteSpeed with free migration, free SSL, daily backups, and crypto payments. 30-day money-back guarantee.

See Hosting Plans

How to defend your machine and your servers

The fix is to stop letting an unknown repo run anything before you have looked at it, and to put real isolation between untrusted code and the systems that matter. Stack these from quickest to most robust.

  1. Turn off auto-run. Disable SessionStart hooks, auto-approved tools, and IDE tasks that execute on folder open. Make your agent ask before it runs a shell command. This single change defeats the detonate-on-open mechanic.
  2. Inspect the dotfolders first. Before opening any cloned repo in an agent, list and read .claude/, .cursor/, .vscode/, .github/, and the scripts block in package.json. Treat any instruction to fetch-and-run as hostile until proven otherwise.
  3. Open untrusted code in a sandbox. Use a disposable container, VM, or dev container with no credentials, no SSH keys, and no production access. If the payload fires, it detonates in a cage you can delete.
  4. Strip secrets from the dev environment. An agent that gets hijacked can only exfiltrate what it can reach. Keep cloud keys, deploy tokens, and CRM credentials out of the shell where you explore new repos.
  5. Pin and review agent rule files in your own repos. Treat .cursor/rules and .claude/settings.json as security-sensitive code. Require review on every change, the same as you would for a CI workflow.

The principle underneath all five: the machine where you read strangers' code should never be the machine that holds the keys to your infrastructure.

Where hosting choices reduce the blast radius

Defense does not stop at the laptop. The second line is making sure a compromised developer machine cannot become a compromised production server. The cleanest way to do that is to never deploy straight from a workstation that touched an unknown repo. Build from a reproducible, locked pipeline, and push the resulting artifact to a server that the developer environment cannot otherwise reach.

Isolation at the hosting layer matters here. Running your sites and apps on a host where each environment is properly segmented — separate from your build machine, with its own credentials and an acceptable-use policy that takes abuse seriously — limits how far a single hijacked agent can spread. LaunchPad Host offshore and privacy-forward plans give you that separation between where you experiment and where you serve real traffic, with crypto-friendly billing and domains under one roof, so a bad repo on your laptop does not put your live infrastructure within arm's reach.

For deploys, prefer signed, immutable artifacts and a CI runner that has no standing access to your repos beyond what a single job needs. The less ambient power an automated agent holds, the less a prompt injection can steal.

A quick checklist before you open any new repo

Turn the lesson into a habit you run every time, so a clean-looking repo never gets a free shot at your environment.

Everything breaks eventually, and the next worm will use a different filename. The durable defense is the assumption behind all of this: a repository is untrusted input until you have personally verified it, and the systems that run your business should be a deliberate hop away from anything you are still inspecting.

Frequently Asked Questions

No. The application source is usually genuinely clean and passes review. The malicious instructions live in agent and IDE configuration files such as .cursor/rules, .claude/settings.json, or a package.json script. These tell your AI coding agent to fetch and run a payload automatically when you open the repository, so a manual code review of the visible source will not reveal anything wrong.

Generally no. Those tools scan declared dependencies for known vulnerabilities, but this attack ships no malicious package. The payload is fetched at runtime based on instructions in a config file, so it never appears in your lockfile. Catching it requires inspecting agent dotfiles before opening a repo and running untrusted code inside an isolated sandbox where you can monitor execution and network calls.

Disabling auto-run on your AI agent and IDE. The 2026 Miasma worm relied on hooks like Claude Code's SessionStart firing the instant a folder opened. If your agent must ask permission before running any shell command, the detonate-on-open mechanic fails. Pair that with opening unknown repositories inside a disposable, credential-free container so anything that does run is trapped in a cage you can delete.

Tags: github security ai coding agents supply chain attack prompt injection devsecops claude code server security

Related tools, articles & authoritative sources

Hand-picked internal pages and external references from sources Google itself considers authoritative on this topic.

Related free tools

Offshore & privacy hosting