DEV Community

Cover image for Your Coding Agent Doesn't Need Your Keys. It Needs a Request Signer.
Gordon Chase
Gordon Chase

Posted on Fully Autonomous

Your Coding Agent Doesn't Need Your Keys. It Needs a Request Signer.

Somewhere on public GitHub right now sits a JSON file listing, in plaintext, every database, SSH host, and cloud endpoint one developer can reach—along with the credentials that open them.

No attacker planted it. No phishing link was clicked. The developer's own coding agent wrote it, one "Yes, and don't ask again" click at a time.

Over the past three weeks, security researchers quantified the wreckage: 104,185 public copies of .claude/settings.local.json, 1,122 of them holding plaintext credentials (CSA / Apiiro). An independent sweep by GitGuardian expanded the lens across settings.json and history and found 31,088 secrets across 23,276 repositories (5,343 still valid at detection)—plus 613 more secrets baked straight into public Docker Hub images via COPY . ..

It is tempting to laugh at developers who forgot .gitignore. That misses the point completely. The November leak wave is not a sloppy-dialog bug—it is what happens when the only way to give a coding agent authority is to hand it the raw secret.


Why Permission Prompts and Secret Scanners Already Lost

Before reaching for a smarter confirmation modal or another pre-commit hook, look at three verified numbers from this year:

  • 97% / 13.6%: In Anthropic's own controlled study of 1,053 testers (Anthropic), developers clicked approve on 97% of permission prompts and caught only 13.6% of planted dangerous commands (and catch rates decay even further under fatigue). Calling a confirmation modal a security boundary is like putting a "Please Don't Knock Over" sticky note on a mug sitting at the edge of a desk.
  • 215 invisible leaks: Out of Apiiro's 1,122 secret-bearing files (containing 1,379 distinct secrets—379 database passwords, 43 public SSH logins, 23 AWS keys), gitleaks caught 564, TruffleHog caught 643, and 215 files were missed by both. Why? Because PGPASSWORD=…, mysql -p…, and sshpass -p … sit inside ordinary shell allow-rules rather than matching high-entropy API-key regexes.
  • One path in every repo: As InfoQ pointed out, .claude/settings.local.json lives at the exact same relative path in every project—making it a tidy, predictable credential index for any malware or Docker build context (COPY . .) that touches the workspace.

Every defense that lives inside the agent's filesystem—.gitignore, output redaction, regex scanners, smarter approval dialogs—is just a filter applied to a copy of a secret that should never have been there in the first place.


The Other Three Doors That Opened in November

If settings-file leaks were the only crack, you could patch one CLI and call it a week. They weren't. November delivered a full taxonomy of why local-laptop agents and multi-tenant SaaS wrappers fail structurally:

  1. The second channel across a sandbox boundary. On November 3, researchers disclosed CVE-2026-103916 (CVSS 8.2) in Docker Sandboxes: the microVM boundary held, but sbx cp—a host-side helper running as the operator—followed workspace symlinks straight onto the host. Two days earlier, JFrog published three CVSS-9.9 escapes in Beta9 (CVE-2026-120306/7/8) where a chroot-only build shared namespaces (/proc/1/root) and a file-API traversal returned the worker's Kubernetes service-account token (agentblog). Even OpenAI's own November 18 Codex sandbox post candidly notes that repo-scoped local jails still allow broad filesystem reads (leaving ~/.aws and ~/.ssh readable) and cannot stop an agent from planting code in node_modules/prettier that your editor executes outside the sandbox.
  2. Instruction-file poisoning and identity hijacking. Forever Security caught a live customer incident where a malicious AGENTS.md dropped into ~/Downloads tried to steer coding agents into installing a malicious npm package—nothing to patch, because obeying AGENTS.md is the feature. And Microsoft Security demonstrated in lab testing how device-code phishing against a coding CLI hands an attacker remote session steering, memory poisoning, and private-repo access using features working completely as designed.
  3. Upstream inference and SaaS blast radius. On November 13, Cursor published its post-mortem: a key exposed at Fireworks led to archived agent traces containing unredacted credentials, which led to a malicious copy of the Claude Code extension served from the marketplace cache for ~11 hours to up to 5,000 users. SecurityWeek tallied at least a dozen AI developer platforms breached in a single month. And on November 20–21, Ars Technica reported HD Moore's 2-million-canary experiment: three compromised providers, AWS bait keys probed within hours, and Zero Data Retention flags ignored at the front door before a model even ran (prompting OpenRouter to pull ZDR labels from MiniMax endpoints).

Every single one of these incidents shares the same root mistake: valuable, long-lived secrets sitting inside—or flowing uninspected out of—the same trust boundary as an untrusted loop.


The Reframe: Secrecy Is Not Authority

When Antonio Mika published Running coding agents without handing them my credentials this month (134 points, 118 comments on HN)—keeping keys on a laptop behind an SSH/MCP proxy (lend) with 5-minute / 3-use leases and biometric prompts—the Hacker News comment section immediately surfaced the sharpest counterargument in this entire space:

"If a proxy will happily run gh pr merge whenever the agent asks, you didn't build a security boundary. You built a key with extra steps."

That objection is dead right—and any security architecture that ignores it is hand-waving.

Hiding the bytes of an API key or Git token from the agent solves exfiltration (the agent cannot dump sk-... into .claude/settings.local.json, a Docker image, or a leaky third-party prompt router). It does not solve abuse of authority unless the custody layer can also refuse.

That is the whole distinction: a raw key can never say no. A policy-enforcing request signer can.

Credential custody boundary diagram: Above the boundary sits an ephemeral rootless Kubernetes Job holding only a short-lived $PROXY_TOKEN with no ~/.ssh, no ~/.aws, automountServiceAccountToken: false, and default-deny NetworkPolicy. Below the boundary sits a control-plane request signer holding KMS-wrapped secrets, enforcing default-deny per-repo, per-ref, and per-method policy before injecting credentials and scrubbing responses.


Four Layers That Actually Hold Under Failure

If you assume the agent process is compromised—by a poisoned AGENTS.md, a prompt injection inside a GitHub issue, or a bad dependency—your job becomes a boring provisioning problem. Give the execution unit nothing worth stealing, and make every privileged action cross a narrow, auditable chokepoint.

Layer 1: The execution unit holds nothing

Stop running unattended or semi-attended agents against your primary workstation—the single highest-value box in the company (~/.ssh, cached prod AWS sessions, live kubeconfig, browser cookies). Run each task in a fresh, ephemeral, rootless container or Kubernetes Job:

securityContext:
  runAsNonRoot: true
  readOnlyRootFilesystem: true
  allowPrivilegeEscalation: false
  capabilities:
    drop: ["ALL"]
automountServiceAccountToken: false
activeDeadlineSeconds: 1800
Enter fullscreen mode Exit fullscreen mode

Two details matter more than people realize:

  • automountServiceAccountToken: false eliminates the exact Kubernetes token-harvesting path seen in Beta9 (CVE-2026-120307).
  • Audit the second doors. Never let a host-side helper resolve workspace symlinks as the operator (sbx cp), never bind an unauthenticated control server to 0.0.0.0, and remember that MCP servers often run outside an agent's shell sandbox.

Layer 2: Default-deny egress, one choke point

Attach a default-deny NetworkPolicy to the task namespace and allow exactly two destinations: cluster DNS and your egress/model proxy on one port. Explicitly block cloud metadata (169.254.169.254)—and verify from inside a running pod that your CNI actually enforces NetworkPolicy, because an unenforced policy YAML is just a comment.

Routing LLM inference through a single gateway you operate also closes the HD Moore canary gap: you pin approved providers, strip accidental secret patterns before prompts leave your network, and prevent an agent or developer config from silently fanning out to an unvetted reseller. (And run that gateway unprivileged—CISA just added LiteLLM's CVE-2026-40217 to KEV, where a guardrail sandbox escape landed straight into a default root container.)

Layer 3: Mint leases, never permanent keys

Inside the sandbox, the agent gets one short-lived $PROXY_TOKEN bound to the execution—never a human PAT, never a raw ANTHROPIC_API_KEY or OPENAI_API_KEY, and never a wildcard GitHub token.

A real execution lease carries tight claims enforced at the proxy:

  • Subject: agent:<repo>:<task-id> (a distinct agent identity, never impersonating a human)
  • Scope: one repository, one working branch (work/<task-id>), contents:write only—never workflows:write, branch-protection bypass, or release publish
  • TTL: hard ceiling (e.g., 30–60 minutes), automatically revoked the moment the Job terminates
  • Policy: default-deny by host, HTTP method, and path—so even a fully hijacked agent cannot turn a branch-push lease into a merge or a force-push to main

If a task goes sideways, revocation is kubectl delete job, not a Friday-evening secret-rotation fire drill across 14 SaaS dashboards.

Layer 4: Bind the review gate to the commit SHA

Remember the Cursor incident: stolen credentials poisoned a marketplace artifact cache for 11 hours, bypassing PR review entirely. And remember GitGuardian's 613 Docker Hub secrets: .gitignore does not stop COPY . ..

Make the commit SHA the only gate that unlocks irreversible actions:

  • Protect main and require human (or policy-service) approval bound to the exact candidate commit SHA and expected base ref—if anything mutates the branch, the approval invalidates.
  • Put CODEOWNERS on .github/workflows/, Containerfile/Dockerfile, package.json scripts, and .claude/ / .codex/ directories.
  • Ban COPY . . in Dockerfiles and add a CI check that fails the build if .claude/, .codex/, .env, or *.pem ever enters the build context (.dockerignore is a polite suggestion; a failing build step is a control).
  • Mint publish credentials via per-job OIDC scoped to one package and one ref—zero long-lived registry tokens anywhere an agent can reach.

What This Architecture Costs You

Any post that pretends isolation is free is hiding where the mess moved. Moving agents off developer laptops into ephemeral Jobs behind a request-signing proxy has real day-two costs:

  • Fidelity drops for bespoke toolchains. A Linux container will not run Xcode, an iOS simulator, or a quirky macOS GUI tool. If that is your stack, you are looking at remote macOS VMs or strict local proxy patterns like lend rather than plain Kubernetes Jobs.
  • Warm caches become explicit work. Ephemeral workspaces mean you have to mount explicit read/write dependency caches (GOMODCACHE, npm, Cargo) or pay cold-build latency on every run.
  • You now own a proxy. A central credential-injecting gateway is a single point of failure—if it crashes or gets misconfigured, every agent stops until you fix it.

Those are honest engineering tradeoffs worth debating. Leaving 31,088 plaintext credentials inside .claude/settings.local.json and hoping humans catch more than 13.6% of bad commands is not a tradeoff—it is waiting for your turn in next month's post-mortem.

A coding agent is a process, not a teammate with a badge. Give it an ephemeral workspace, a deadline, and a scoped request handle—never a raw key.

How are you keeping ~/.ssh, .env, and provider keys out of reach of your coding agents right now—and where has sandboxing broken your workflow?

Top comments (0)