When Claude Code runs git push, GitHub sees the engineer’s SSH key, laptop and IP address, and nothing in the connection says an agent typed the command. Formal Endpoint tells the two apart by the process that opened the connection, then applies policy to what the agent sends.

What is AI coding agent security?

AI coding agent security is the set of controls on what coding agents such as Claude Code, Codex, Cursor and Devin can reach, which credentials they can use, which of their actions need a person, and whose name goes on each request. It covers the agent at runtime, on a developer’s laptop or in a cloud VM, rather than the code it produces.

People searching for AI coding assistant security often mean an older problem: an autocomplete that suggests code a developer accepts or rejects. Review works for that. It stops working once the tool runs the tests, installs the package and pushes the branch on its own, because by the time anyone reviews, the actions already happened. An AI coding agent security platform puts the controls where those actions happen.

Code scanning is a separate job: SAST, dependency scanning and the AI fix agents built on them check what the agent wrote. Formal doesn’t scan code. It sits on the connections, next to whatever scanner you run. Coding agents are also only one kind of AI agent; AI agent security at the egress covers the others with the same Endpoint.

What are the biggest AI coding agent risks?

The biggest AI coding agent risks come from an agent using its engineer’s access for something the task didn’t need: a push to a repository that should only take human commits, an API call made with a key it found in .env, a token pasted into a clone URL, a call to an MCP server nobody approved, an auto-merge on a pull request nobody read, and a cloud agent run nobody can trace to a person.

Most threat models for coding agents start from prompt injection, and it’s often how one of these starts: malicious instructions in a README or a code comment that the agent follows. Whether the agent is compromised or just wrong, the damage still travels over a connection it opens, so the connections are the attack surface we control. OWASP calls the underlying flaw excessive agency, an agent holding more permissions and reach than its job requires. We’d rather check the push than try to spot every injected prompt, because the push looks the same on the wire whatever talked the agent into it.

Controls inside the agent, and controls outside it

Claude Code ships real controls: permission prompts, Bash allowlists, a sandbox and hooks. Use them. They’re settings of the agent, though, and whoever runs claude --dangerously-skip-permissions or edits settings.json changes them.

Our engineers found the gaps by trying. Allowlisting go test turns out to allow any command, because the agent can edit a test file to call exec.Command (the full list). Anthropic’s devcontainer firewall allows hosts by IP address, so it can’t tell a clone from a push, or an upload from a download, on a host it allows (proxies and Claude Code). Hooks see the tool call before it runs, and we tested where they fail open and who can turn them off.

So keep the in-agent controls for speed and to cut down on prompts, and put the checks you’d show an auditor on the network path. They hold there whatever the agent’s configuration says.

Telling the agent from the engineer on one laptop

Transparent Mode hooks Formal Endpoint into the operating system’s networking (a Network Extension on macOS), so Claude Code and the tools it runs need no proxy settings. Network rules written in CEL decide which of those connections Formal inspects, in up to three stages. This one, from the docs recipe for blocking agent pushes, selects git traffic to GitHub from any known agent:

{
  "condition": {
    "pre_tcp": process.has_agent_ancestor,
    "pre_tls": hostname in ["github.com", "ssh.github.com"],
    "post_tls": technology in ["http", "ssh"]
  }
}

pre_tcp runs before the connection is diverted and sees the process that opened it, plus its ancestors. On macOS, the Endpoint compares each process’s code identifier, bundle identifier and signing team against the known agent identities table. process.has_agent_ancestor is true for a known agent and for anything it spawned, which matters because Claude Code doesn’t push code itself: it runs git, which runs ssh or git-remote-https. pre_tls narrows the rule to GitHub’s hosts, and post_tls keeps HTTP and SSH once Formal has classified the protocol.

The engineer’s own terminal has no agent in its process tree, so the same push typed by hand never matches. Neither does a tool missing from the table: the rule only knows the agents Formal recognizes, and a binary from another signing team isn’t one of them. On Linux there’s no code signature to check, so per-agent flags such as process.is_claude_cli and process.is_codex_cli_rs match process names (claude, codex) instead, and the ancestor-based push recipe is macOS only.

Blocking agent pushes, not engineer pushes

Git reaches GitHub three ways: SSH on port 22, SSH on port 443 at ssh.github.com, and HTTPS. A control that covers only one of them is bypassed by changing the remote URL.

The block agent git pushes policy reads the push from both protocols. Over SSH, a push runs git-receive-pack on the server, and a session rule finds it in input.ssh.command. Over HTTPS it’s a POST to /git-receive-pack, which a request rule reads from input.http. Clones and fetches use git-upload-pack and keep working. The SSH half, from the docs:

session := block if {
  input.resource.hostname in hostnames
  contains(input.ssh.command, "git-receive-pack")
  some repository in repositories
  contains(input.ssh.command, repository)
}

The repository match is a substring, so listing acme/infrastructure also blocks acme/infrastructure-docs. Usually that’s what you want; check the list before you activate it. If a hard block is too strict, the mfa action pauses the agent on the push until the engineer confirms on their device.

To test it, ask Claude Code to clone a protected repository, change the README, commit and push. The clone succeeds, the push fails with a Formal block message, and the same push from your terminal goes through.

How do you keep API keys and tokens away from coding agents?

Keep the credential on a Formal Connector and let the proxy add it after the request has left the agent. The Endpoint forwards selected requests with the engineer’s Formal identity, a Native User sets the header, and the laptop or agent VM never stores the key. In our Anthropic walkthrough, Claude Code runs with ANTHROPIC_API_KEY=sk-ant-dummy, and the API answers as if that were a valid key.

The same setup works for any HTTP API. Keep Stripe API keys off laptops stores the Stripe key as an environment variable on the Connector, builds the Authorization: Bearer header from it and adds a policy that lets one group read balances, charges and customers while blocking refunds and every other write. Using proxies to hide secrets from Claude Code walks through the Anthropic version with Terraform.

Tokens in clone URLs

Git tokens are harder, because agents put them in commands. An agent that clones with https://x-access-token:$GITHUB_TOKEN@github.com/acme/app.git never shows the token in its tool call: the shell expands the variable afterwards, so the real token ends up in the command line of git and of the git-remote-https process it starts. For intercepted connections, the Endpoint records those command lines in the session log, and it doesn’t look for credentials in them. It redacts the Authorization header Git sends; the command line stays as-is.

Protect Git tokens in command lines handles both ends. A log schema encrypts the command line fields on the device, before the log leaves it. A response policy on LLM traffic blocks any tool call whose arguments carry a GitHub token prefix (ghp_, github_pat_, ghs_ and the rest of GitHub’s token formats) or a URL with credentials in it, a pattern that also catches the unexpanded $GITHUB_TOKEN@ form. It won’t catch a token passed through a credential helper, a script file or a variable outside a URL, and the docs say so.

Cloud coding agents and the person behind each run

A cloud agent has no laptop and often no single user: anyone on the team can start one from Slack, Linear or GitHub. The questions change from “which process is this?” to “which run is this, and who asked for it?”

The Endpoint answers them from inside the agent environment. You install the headless Debian package when the Cursor Cloud Agent or Devin environment is built, and configure it to sign in with the platform’s OIDC token and fail closed. From the cloud agents guide:

auth_mode = "oidc"

[oidc]
provider = "cursor"
integration_id = "integrationoidc_..."

[transparent_proxy]
enable = true
enforce = true
fail = "closed"

Each run signs in with the token its platform already issues, and the resulting Formal session renews itself, so there’s no Formal API key to steal from the VM. The OIDC integration maps claims.owner_email (Cursor) or claims.requesting_user_email (Devin) to a Formal user, and every request is logged under both the agent’s machine user and that person. The two identities carry different trust: Formal verifies the machine identity cryptographically, while the human identity is asserted by the agent platform, and you decide to trust it the way you’d trust a BI tool to report who is logged in. Giving cloud agents production access with OIDC explains how we use this on our own infrastructure.

Two policies close the loop. A Control Plane Permission denies the machine user every Formal API except Endpoint sign-in and logging, so an agent can’t edit its own rules. A merge policy blocks enablePullRequestAutoMerge, enqueuePullRequest and mergePullRequest in GitHub GraphQL, walking named and inline fragments because a mutation can hide there, plus the REST merge endpoint. The agent can open and update pull requests; a person merges them.

“Without Formal, we couldn’t have agents with access to sensitive data. With Formal, because we are able to inspect all traffic and enforce controls, we are able to provide a safe environment for the agents to get the job done.”

— Travis McPeak, Head of Security @ Cursor

The Cursor case study shows the result: Cursor’s security team scopes what a Cloud Agent workflow can reach and what the employee behind it may do, as two separate checks.

Claude Code, Cursor, OpenAI Codex and Devin

Each tool has its own quirks; the network rules and policies above apply to all of them.

Claude Code

Claude Code can read the environment variables of the terminal you start it from and the files in its working directory, .env included. Claude Code security covers its network reach, secrets, usage monitoring and the skills and MCP servers it loads.

Cursor

Cursor’s agent works in the editor on an engineer’s machine and, as Cursor Cloud Agents, in hosted environments. Cursor security covers both, from per-agent rules on the laptop to OIDC sign-in and blocked merges in the cloud.

OpenAI Codex security

There’s no Codex integration page yet. The Endpoint recognizes Codex by signature on macOS and by the codex process name on Linux, and Restrict Codex Desktop to LLM and MCP is the recipe for keeping Codex Desktop to its model and your approved MCP servers.

Devin

Devin security covers the OIDC sign-in, just-in-time database access and egress for Devin sessions, with each action mapped to the person who started the session.

MCP servers and skills the agent loads

An MCP server or a skill changes what a coding agent can do, and which sensitive data it can reach, without touching its code. Because the Endpoint classifies MCP and LLM traffic, a rule on known agents feeds Formal’s AI governance pages: the Catalog of approved MCP servers and skills with who may use each one, Shadow AI review for the ones people use anyway, and Guardrails that decide what happens to those meanwhile. Those pages read logs, so they only show traffic that goes through the Endpoint or a Connector.

Shadow AI covers discovery of unapproved servers and skills, and the MCP gateway covers per-tool access to the approved ones.

What should an AI coding agent security platform enforce?

An AI coding agent security platform should enforce controls the agent can’t edit, tell the agent from its engineer on the same machine, keep credentials out of the agent’s environment, name a person for each cloud run, and let you test a rule before it blocks anyone. When you compare vendors, ask where each control runs and what happens when it can’t reach its backend.

Questions worth asking any vendor that offers to secure AI coding agents, Formal included:

  • Where does enforcement run: in the agent’s settings, an IDE extension, the operating system’s network layer, or a gateway in your network?
  • Does it block the action, or detect it and alert afterwards?
  • Does a rule see the process that opened the connection, including children like git and ssh?
  • Can the agent use a credential without ever holding it?
  • For cloud agents, does each run carry the identity of whoever started it, and does the sandbox fail closed?
  • Can a policy run in dry-run, and what does the agent see when it’s blocked?
  • Which agents, platforms and protocols aren’t covered?

Our answers: enforcement in the network layer on macOS and Linux, in cloud agent VMs and in Kubernetes and ECS sidecars; a block or an MFA pause on the connection itself, with Logs for review afterwards; process identity from code signatures on macOS and process names on Linux; tools outside the known agent table aren’t intercepted; no code scanning. Running cloud agents against our own infrastructure taught our engineers to model agent access as a temporary delegation from a named person, and that’s the shape these controls give it.