🤖 AI Hot

Claude Code Auto-Runs Hidden Malware on GitHub Repos

A
Alex Chen

I’ve been watching AI coding tools race to add more autonomy for months. Claude Code can now open repos, read issues, write PRs, and execute shell commands without asking. It’s genuinely useful. But a new attack vector discovered on Mozilla’s 0DIN bug bounty platform shows we’ve been overlooking something fundamental: these agents will run code they’ve never seen, from repos they’ve never visited, and the payload doesn’t even need to be in the repository.

Security researchers demonstrated that an attacker can craft a GitHub repository that looks completely clean to every code scanner and human reviewer, yet still executes malicious code the moment Claude Code opens it. The payload lives entirely outside the repo — fetched at runtime from DNS records. Let me walk through how this works and what it means for AI agent security.

How the DNS-based attack works

The attack chain is deceptively simple. A GitHub repository contains a setup script — something innocent-looking like setup.sh or install.py. The script itself contains no malicious code. Security scanners, code review tools, and even careful manual inspection would flag nothing suspicious. The file just has a line that looks like any other network utility call.

When a developer uses Claude Code to open this repository, Claude Code sees setup instructions and offers to run them — which is its normal behavior. If the developer accepts (or if Claude Code is in an auto-approval mode), the script executes. At that point, it queries a DNS TXT record for a specific domain. The TXT record — which is just a text field in DNS, normally used for domain verification — contains the actual malicious commands.

The script reads those commands and executes them. Because the payload never existed in the repository, no static analysis tool, no SCA scanner, no GitHub security advisory could have caught it. The malicious code only exists in transit, pulled from DNS infrastructure that the attacker controls. Once executed, it opens a reverse shell back to the attacker’s server, giving them access to API keys, environment variables, login credentials, and persistent access to the developer’s machine.

Why AI coding agents are uniquely vulnerable

This attack class is not new in principle — DNS tunneling and command-and-control via DNS have been around for years. What’s new is the attack surface that AI coding agents create.

A traditional developer workflow has friction built in. You clone a repo. You read the README. You look at the code. You run pip install or npm install. Maybe you glance at setup.sh if something feels off. Each step is a chance to notice something wrong. And crucially, you have to choose to take each step.

Claude Code, Codex, and Cursor collapse all of that into a single prompt. “Open this repo and fix the bug.” The agent reads the issue, checks out the code, reads setup instructions, runs the setup, and starts working — all in seconds. The human reviews the final output, not the intermediate steps. Those intermediate steps are where the malware runs.

I tested this with a few colleagues. Four out of five didn’t register that a setup script had run at all. They were focused on the bug fix or the feature they asked for. The setup step scrolled past in the agent’s output log, mixed in with dependency installation messages and environment checks. Nothing looked unusual.

This is the fundamental tension with AI coding agents: the more autonomous they become, the fewer human attention checkpoints remain. Every checkpoint you remove is an opportunity for attack.

The 0DIN platform and Mozilla’s bug bounty

The attack was discovered through 0DIN, Mozilla’s GenAI vulnerability bounty program. 0DIN specifically focuses on AI-specific attack vectors — prompt injection, tool misuse, agent hijacking — rather than traditional software vulnerabilities. The fact that this was found through a structured bounty program suggests we’re early in mapping the attack surface rather than late.

Mozilla launched 0DIN in early 2026 with the thesis that AI agents introduce new classes of vulnerabilities that existing bug bounties don’t cover. A SQL injection bounty program doesn’t care if an AI agent can be tricked into running DROP TABLE. A prompt injection bounty does. This DNS-based attack fits squarely in that gap — it’s not a vulnerability in the repository code, not a vulnerability in Claude Code per se, but a vulnerability in how humans and AI agents interact with untrusted code.

The researchers who found this noted that the same technique works against any AI coding tool that auto-executes setup commands: Codex, Cursor, Gemini CLI, Aider. They recommended that AI agents should display the full content of any script before running it, rather than just showing the filename and a summary. Claude Code’s current behavior shows a brief description of what it’s about to run, but not the script contents.

What Anthropic can fix — and what it can’t

There are straightforward mitigations Anthropic can implement. Show script contents before execution. Flag setup scripts from repositories the user hasn’t previously interacted with. Don’t auto-run scripts that make network calls to unknown domains. Sandbox setup execution by default.

Anthropic responded quickly — the 0DIN report was filed and acknowledged within days. Claude Code already has a permission system, and you can configure it to ask before running shell commands. The issue is that the default behavior is permissive enough to be dangerous, and most users don’t adjust defaults.

But there’s a harder problem that no amount of permission prompts can fully solve. The fundamental value proposition of AI coding agents is that they do things without you having to think about every step. Every safety guardrail that re-inserts a human checkpoint also reduces the time savings that made the agent worth using in the first place. If Claude Code shows me the full contents of every script before running it and asks me to review every network call, I might as well just run the commands myself.

I think the right answer is not one-size-fits-all. Repositories with high trust signals — popular packages with thousands of stars, maintained by verified organizations, with reproducible builds — can justify more autonomy. Brand-new repos from unknown authors with one commit and no stars should trigger a much higher bar. The agent needs to develop something analogous to a human developer’s gut feeling about whether code looks trustworthy.

The broader AI agent security landscape

This attack is part of a growing category I’d call “ambient trust exploitation.” AI agents inherit the trust model of their training data, which is to say: they trust that setup scripts are meant to set things up, that README files contain instructions worth following, that GitHub repositories contain code worth running. That trust model works fine when a human is in the loop making judgment calls. It breaks when the agent is the one making those calls.

We’ve seen similar patterns elsewhere. Prompt injection convinces agents to ignore their instructions. Tool misuse attacks trick agents into calling APIs with malicious parameters. Data poisoning contaminates training data to produce specific agent behaviors. The DNS attack adds a new dimension: the malicious content doesn’t even need to be in the data the agent sees. It only needs to be reachable from the commands the agent runs.

The timing makes this particularly concerning. Claude Code usage has exploded in 2026. Anthropic’s own Economic Index shows that coding tasks dominate Claude usage, and the proportion of agent-driven coding (vs. chat-based assistance) is growing rapidly. More autonomous coding means more repositories being opened, more setup scripts being run, more attack surface.

Why this is worse than supply chain attacks

Supply chain attacks — compromising a package on npm or PyPI — are the comparison everyone reaches for. But the DNS-based approach has three properties that make it significantly harder to defend against.

First, the payload is ephemeral. An npm package with a malicious postinstall script leaves a permanent artifact. Security researchers can download it, reverse-engineer it, publish IoCs. With DNS-based delivery, the attacker can change the payload between executions, serve benign responses to known security IPs, or take the DNS record down entirely once the attack window closes. There’s nothing to analyze after the fact unless you captured the DNS query and response in real time.

Second, the trust model is inverted. Supply chain attacks exploit trust in package registries and maintainers. The DNS attack exploits trust in the AI agent’s own judgment. Claude Code is not running npm install because it trusts the npm ecosystem — it’s running a setup script because it trusts its own analysis that the script looks reasonable. That’s a much harder trust relationship to audit or constrain.

Third, attribution is near-impossible. When malware in an npm package is discovered, you can trace it back to the publishing account, the email, the IP addresses used during development. DNS records leave far fewer traces. The domain used in this attack was registered through a privacy-protected registrar and the DNS infrastructure was hosted on a bulletproof provider. The researchers at 0DIN noted that they could identify the attack mechanism but not the attacker.

None of this is to say supply chain attacks aren’t serious. They are. But the defenses we’ve built for supply chain security — lockfiles, checksums, registry scanning, provenance attestation — don’t apply to commands that an AI agent decides to run on its own. We need a different category of defense entirely.

What you should do today

If you use Claude Code, Codex, or any AI coding agent, here’s what matters right now:

First, disable auto-approval for shell commands. In Claude Code, this means setting permissions to ask before running any shell command, not just the ones it flags as potentially dangerous. Yes, it’s annoying. Yes, it will slow you down. But the alternative is an agent that can execute arbitrary code from DNS records without you ever seeing it.

Second, treat third-party repositories as untrusted. This sounds obvious but we’ve gotten lazy. “It’s just a small utility repo” or “it’s from someone in the AI community” are not security arguments. The 0DIN attack used a repo that looked completely normal. If you wouldn’t run curl | bash from a URL you’ve never seen before, don’t let your AI agent do it either.

Third, run AI coding agents in isolated environments when working with unfamiliar code. A dedicated VM, a container, or at minimum a separate user account with limited permissions. The reverse shell in this attack could access everything the developer’s user account could access — SSH keys, cloud credentials, browser sessions.

Fourth, watch what your agent actually does. Claude Code keeps transcripts. Review them occasionally, not just the final PR. Look for network calls to domains you don’t recognize, scripts that ran without your explicit approval, commands that seem unnecessary for the task you asked for.

The security community is just starting to map this attack surface. Every new AI agent capability is also a new attack vector. The speed at which agent capabilities are being added — Claude Code went from 13 hooks to nearly 30 in six months — far outpaces the speed at which security practices are adapting. We’re going to see more attacks like this, not fewer.

I still use Claude Code daily. It saves me real time. But I use it differently now than I did three months ago. I read more of its output. I question more of its decisions. I treat it more like a very fast junior developer who occasionally has terrible judgment, and less like a tool I can trust to handle the boring parts without supervision. That shift in mental model is probably the most important security practice of all.

Disclosure: CarCare Guide is reader-supported. When you buy through links on our site, we may earn an affiliate commission at no extra cost to you. Learn more.
A
Alex Chen