Skip to content

Get notified

Get an email when a new major security incident drops. No spam, unsubscribe any time.

Only used for pwn.watch incident emails. Protected by Cloudflare Turnstile.

Supply Chain & SBOM9 min read

Securing AI Coding Agents on Developer Workstations and CI (2026)

How to run AI coding agents (Claude Code, Cursor, Copilot, Codex, Gemini CLI) safely on laptops and CI runners: credential isolation, filesystem sandboxing, prompt-injected dependencies and rules files, extension provenance, and egress monitoring.

// key takeaways

  • A coding agent has the same reach as the developer who runs it: shell, filesystem, git remotes, package registries, and every credential in the environment. Scope that reach before it reads untrusted text.
  • Attackers already target agents directly. Malicious packages have used local AI CLIs to hunt for secrets, and a trojanized agent extension shipped through an IDE marketplace.
  • Rules files, READMEs, issues, and dependency source are all input the model reads. Review changes to agent instruction files like code, and never let CI agents act on untrusted issue text with write tokens.
  • Log and restrict egress. An agent that can reach any host can exfiltrate anything it can read.

Why coding agents change the developer attack surface

A traditional malicious dependency has to bring its own code to find secrets. An agent on the same machine is already a capable, authenticated tool that can search the disk, run commands, and push to git. The s1ngularity compromise of Nx packages, tracked on pwn.watch, showed this: the malicious postinstall script invoked locally installed AI CLIs to look for secrets and then published what it found.

The agent itself is also a supply-chain component. Cursor reported that a modified build of the Claude Code VS Code extension was briefly available in its extension marketplace and planted an SSH key on affected machines. Earlier, the GlassWorm worm spread through VS Code and OpenVSX extensions. Extensions, CLIs, MCP servers, and model gateways all deserve the same provenance checks as npm or PyPI packages.

  • Inputs the agent reads: repository files, rules files, issues, PR comments, web pages, tool results, and dependency source.
  • Capabilities the agent has: shell, file write, git push, package install, browser, and any MCP tools.
  • Credentials it can reach: environment variables, ~/.aws, ~/.ssh, ~/.npmrc, git credential helpers, cloud CLIs, and saved agent settings.
  • Places it can send data: any host the machine can reach, unless egress is restricted.

Credential isolation on workstations

Most developer laptops hold long-lived tokens in plain files and environment variables. An agent session inherits all of them. Split what the agent needs from what you have: a dedicated low-privilege git identity or fine-grained token for agent work, no cloud admin credentials in the agent's shell, and secrets fetched on demand from a manager instead of exported globally.

Watch for secrets that agents write to disk themselves. Researchers found that Claude Code could save a command, including a typed password or token, as an allow rule in .claude/settings.local.json, and thousands of those files had been pushed to public GitHub repositories. Any agent setting file, transcript, or cache in the repo can leak this way.

  • Start agent sessions from a clean shell that does not export cloud, registry, or production tokens.
  • Use fine-grained, repository-scoped tokens for agent git access, and prefer short-lived credentials from an SSO broker.
  • Add agent local settings and caches to the project .gitignore (not only your global excludes) and run secret scanning on commits and pre-push.
  • Never type secrets into a command you approve with 'always allow'. Use environment references or a secret manager CLI instead.
  • Keep SSH keys behind an agent with confirmation, or a hardware key, so a background process cannot use them silently.
Find agent settings and secrets that should not be committed
# Agent local settings that should never be tracked
git ls-files | grep -E '(^|/)\.claude/settings\.local\.json$|(^|/)\.env(\..*)?$' && echo 'review: tracked local settings'

# Make sure the project ignores them for every contributor, not just you
printf '%s\n' '.claude/settings.local.json' '.env' '.env.*' >> .gitignore

# Scan history and staged changes for credentials before pushing
gitleaks git --redact --no-banner .
gitleaks git --staged --redact --no-banner .

Filesystem and process sandboxing

Run agents in a boundary that matches the task. For routine work in one repository, a dev container or VM with only that repository mounted removes the agent's view of your home directory, SSH keys, and browser profiles. Many agent CLIs also ship their own permission modes and OS sandboxes. Use them, but do not rely on approval prompts alone, because prompts that appear often get approved without reading.

Separate read, write, and execute permissions. Let the agent read the repository freely, write only inside the working tree, and run commands from an allowlist. Disable lifecycle scripts during installs the agent triggers, so a malicious package cannot execute on install.

  • Use a dev container, VM, or disposable cloud workspace per agent task, mounting only the repository.
  • Deny reads of ~/.ssh, ~/.aws, ~/.config/gcloud, ~/.npmrc, ~/.docker, and browser profile directories.
  • Allowlist commands (test, lint, build) instead of granting arbitrary shell, and require approval for installs, network tools, and git push.
  • Install dependencies with lifecycle scripts disabled (for example npm ci --ignore-scripts) and run builds in the sandbox.
  • Throw away the environment after the task so nothing persists between sessions.

Prompt-injected dependencies, rules files, and CI triggers

Agents follow instruction files such as AGENTS.md, CLAUDE.md, .cursor/rules, and copilot-instructions.md. A pull request or dependency that edits those files changes what the agent will do next time. Comments in vendored code, package READMEs, and test fixtures can carry instructions too, sometimes hidden with invisible Unicode, a technique GlassWorm used to hide its payload.

CI is where this gets dangerous, because runners hold deploy keys and write tokens. The Gemini CLI issue-triage workflow flaw tracked on pwn.watch let anyone who opened a crafted GitHub issue run commands on the runner and read tokens. Treat any agent workflow triggered by issues, comments, or forks as processing hostile input.

  • Put agent instruction files under CODEOWNERS and require review for changes to them.
  • Scan instruction files and diffs for invisible Unicode and for text addressed to AI assistants.
  • In CI, run agents on untrusted events with read-only tokens (permissions: contents: read), no secrets, and persist-credentials: false on checkout.
  • Split untrusted triage (read issues, propose labels) from privileged actions (push, release, deploy) into separate jobs with separate tokens.
  • Pin GitHub Actions and agent CLIs to commit SHAs or exact versions, and review updates like any dependency.
Least-privilege GitHub Actions job for an agent on untrusted input
on:
  issues:
    types: [opened]
permissions:
  contents: read
  issues: write   # only what the triage step needs
jobs:
  triage:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<pinned-sha>
        with:
          persist-credentials: false
      # Pass issue text as data via env, never interpolate it into run: scripts
      - name: Triage
        env:
          ISSUE_BODY: ${{ github.event.issue.body }}
        run: ./scripts/triage.sh

Egress monitoring and detection

Exfiltration needs a network path. Restrict where agent sandboxes and CI runners can connect: the model API, your package registry or proxy, your git host, and little else. Log DNS and outbound connections so you can answer what an agent contacted during an incident.

Agents also leak data through ordinary requests. Users reported that Claude Code put the signed-in account email into User-Agent headers of requests it wrote to third-party sites. Egress logs make these leaks visible, and an allowlist keeps them small.

  • Route agent and CI traffic through an egress proxy with a host allowlist and request logging.
  • Alert on new destinations, paste sites, raw IPs, and unexpected git pushes or repository creation from agent identities.
  • Use a registry proxy so package installs come from one audited source.
  • Keep agent transcripts and tool-call logs for the same retention period as shell history on servers.

// actionable engineering checklist

  • Inventory agents, extensions, and versions

    List every AI coding agent, IDE extension, CLI, and MCP server in use on laptops and runners, with pinned versions and approved sources.

  • Separate agent credentials

    Fine-grained, short-lived tokens for agent work. No cloud admin, registry publish, or production credentials in agent sessions.

  • Sandbox the filesystem

    Dev container or VM per task, repository-only mounts, no access to SSH keys, cloud configs, or browser profiles.

  • Ignore and scan agent settings

    Add agent local settings to .gitignore and run secret scanning pre-commit and in CI.

  • Review instruction files like code

    CODEOWNERS on AGENTS.md, CLAUDE.md, .cursor/rules and similar files, with checks for invisible Unicode.

  • Lock down CI agent workflows

    Read-only tokens and no secrets on untrusted triggers, persist-credentials: false, pinned actions, and untrusted text passed only via env.

  • Restrict and log egress

    Host allowlist for agent sandboxes and runners, with DNS and connection logs kept for incident response.

// connected pwn.watch tools & live trackers

Frequently Asked Questions

What is the biggest risk of running an AI coding agent locally?
Credential reach. The agent inherits your shell environment and filesystem, so any instruction it follows can read tokens, SSH keys, and cloud configs and send them out. Run agents in a sandbox without those credentials and restrict network egress.
Can a dependency attack my coding agent?
Yes, in two ways. Malicious install scripts can call agent CLIs on the machine, as the s1ngularity Nx compromise did, and package source or READMEs can contain instructions the agent reads. Install with lifecycle scripts disabled inside a sandbox and review what the agent adds.
Should agent rules files like AGENTS.md be code-reviewed?
Yes. They change agent behavior for everyone who works in the repository. Put them under CODEOWNERS, review changes, and check for hidden Unicode or instructions that grant extra permissions.
How do I safely run an AI agent in GitHub Actions?
Give jobs triggered by issues, comments, or forks read-only permissions and no secrets, set persist-credentials: false, pin actions to SHAs, and pass untrusted text through environment variables instead of interpolating it into scripts. Run privileged steps in separate jobs.

Get an email when a new major security incident drops. No spam, unsubscribe any time.