What Happened
Mozilla's Zero Day Investigative Network (0DIN) demonstrated an attack exploiting AI coding agents through legitimate-looking GitHub repositories. The repository contained no malicious code. Instead, the attack weaponized the AI agent's error recovery process.
When Claude Code cloned the repository and attempted to run the project, it encountered a deliberate build failure. The agent, following its programmed behavior to troubleshoot and resolve errors, executed a series of commands suggested by error messages. These commands triggered a shell script that queried attacker-controlled DNS records, which returned and executed a malicious payload.
The attack chain ran automatically. No developer intervention occurred between the initial clone and the payload execution.
Timeline
T+0: AI agent clones repository containing intentionally broken build configuration
T+1: Build fails with error message suggesting troubleshooting commands
T+2: Agent executes suggested shell commands to resolve the error
T+3: Shell script queries DNS TXT records from attacker-controlled domain
T+4: DNS response contains encoded commands
T+5: Agent executes commands from DNS response, establishing backdoor
The entire sequence completed in seconds. The agent's logs showed the execution chain, but the speed and automation meant no human review occurred before compromise.
Which Controls Failed or Were Missing
Input Validation: The agent accepted and executed commands from external sources (DNS records) without validation. The error message became a trusted input vector.
Least Privilege: The agent operated with sufficient privileges to execute arbitrary shell commands and network operations. No sandbox or restricted execution environment limited its capabilities.
Execution Visibility: The agent disclosed individual commands in its logs, but it did not present the full execution chain for approval before running multi-step operations. A developer reviewing the logs would see "running npm install" and "executing setup script" but not "this script will query DNS and execute the response."
Change Management: No approval gate existed between "build failed" and "execute these commands to fix it." The agent's troubleshooting behavior bypassed any review process.
Network Egress Controls: The agent could query arbitrary DNS records and make outbound connections without restriction. DNS, typically allowed through most firewalls, became an exfiltration and command channel.
What the Standards Require
PCI DSS v4.0.1 Requirement 6.4.3 mandates that scripts run in production environments are reviewed and authorized before execution. While development environments often get exempted from this control, the requirement's principle applies: automated execution of scripts, especially those triggered by external input, needs human review.
OWASP ASVS v4.0.3 Section 5.1.1 requires input validation for all sources. DNS responses, error messages, and build outputs all qualify as untrusted input when they influence execution flow. The agent treated error messages as trusted instructions.
NIST 800-53 Rev 5 Control AC-6 requires least privilege. An AI agent performing code operations needs write access to the working directory, but it doesn't need unrestricted shell execution or arbitrary network access. The control calls for privilege separation—read/write file operations in one context, command execution in another, each with appropriate restrictions.
ISO/IEC 27001:2022 Control 8.32 addresses change management for production systems. When an AI agent automatically modifies code, installs dependencies, or executes setup scripts, those changes need the same review as human-initiated changes. The standard doesn't exempt automated processes from change control.
Lessons and Action Items for Your Team
Implement Execution Chain Disclosure
Configure AI coding agents to display the complete command sequence before execution. When the agent says "I'll fix this build error," it should show:
- The initial command it plans to run
- Any commands that command might trigger
- External resources those commands will access
- The final state after execution
0DIN's recommendation for full execution chain disclosure addresses this directly. Your team needs to see "this will run a script that queries DNS and executes the response" not just "running setup.sh."
Apply Least Privilege to Agent Contexts
Run AI agents in containers or VMs with restricted capabilities:
- Read-only access to source repositories
- Write access only to designated build directories
- No direct shell execution—commands go through an approval API
- Network access limited to known package registries
If your agent needs to run npm install, it should do so in an environment that can't execute arbitrary shell commands or make DNS queries to attacker-controlled domains.
Treat Agent Decisions as Untrusted Input
Error messages, build outputs, and repository contents all become attack vectors when an AI agent processes them. Apply the same input validation you'd use for user-supplied data:
- Validate commands against an allowlist before execution
- Parse error messages programmatically rather than letting the agent interpret them as natural language instructions
- Sanitize any external input (including DNS responses) before processing
Add Approval Gates for Multi-Step Operations
When an agent proposes a fix that involves multiple commands or external network access, require human approval. Your CI/CD pipeline already has approval gates for production deployments—extend that pattern to agent-initiated changes.
Implement a rule: any operation that combines file system writes with network access requires explicit approval. This would have caught the DNS query attack.
Monitor DNS as a Command Channel
Your security monitoring likely watches for DNS tunneling and exfiltration, but add specific detection for:
- Build environments making DNS queries to recently registered domains
- TXT record queries from development systems
- DNS responses containing base64 or encoded content
- Queries to domains not associated with known package registries
The attack used DNS because it's rarely blocked and often unmonitored. Close that gap.
Document Agent Capabilities in Threat Models
Update your threat models to include AI agents as potential attack vectors. Document:
- What systems the agent can access
- What commands it can execute
- What network resources it can reach
- How it makes decisions about running code
Then apply your existing security controls to those capabilities. An AI agent with shell access needs the same monitoring and restrictions as a service account with shell access.
The clean repository attack works because AI agents optimize for automation over security. Your job is to add the security controls that restore the balance.



