Securing Claude Code, Cursor and Codex in the enterprise

Reviewed

In short: Coding agents run on developer laptops with the developer's own access, so treat them as agents, not as editors. Give them their own identity where tools allow it and keep secrets out of the shell they can read. List the MCP servers each laptop runs. Log which commands and tools each session used.

6 min read

NewCore documents a gateway that checks each tool call before execution. That is an enforcement example, not evidence of a specific endpoint sensor.

Why are coding agents a special case?

Most agent governance assumes a server-side agent with its own service identity. Coding agents break that assumption. Tools such as Claude Code, Cursor and Codex run inside a developer's terminal or editor. They read the working directory, run shell commands and call the code host with whatever credentials the developer has.

That means a coding agent can usually do anything its developer can do from that machine. If the developer has production cloud keys in their shell, so does the agent. If the developer can push to the main branch, so can the agent.

This guide covers generic controls. Each tool documents its own settings, and those change often. Check the vendor's current documentation before relying on any specific feature.

Which risks matter most?

  • Inherited access: the agent uses the developer's tokens, keys and SSH credentials.
  • Untrusted input: the agent reads issues, pull requests, dependencies and web pages that may contain injected instructions.
  • Local MCP servers: developers add servers to their laptop configuration, often from unknown authors.
  • Shell commands: an agent that can run commands can read files, call networks and install packages.
  • Weak evidence: local actions often leave no central record of what the agent did.

OWASP's guidance on prompt injection applies directly. A comment in a repository can tell an agent to read a secrets file and post it somewhere. The agent may not know it is being steered.

How should coding agents get an identity?

The goal is that the code host, the cloud and other services can tell an agent's action from the developer's own. Where a tool supports it, sign the agent in with its own OAuth client and scoped token rather than reusing the developer's personal token.

Where that is not possible, narrow what the developer's session carries. Use short-lived cloud credentials issued per session instead of static keys in configuration files. Require branch protection so that agent commits still go through review.

How do you handle MCP servers on laptops?

Local MCP servers are the least visible part of the estate. They start as processes on the laptop, often with access to files and network. Discovery that only watches network gateways will miss them.

Keep an approved list of servers and versions. Use endpoint tooling to report which servers each laptop runs. Some agent security products describe endpoint sensors for this, such as Astrix's EDR and browser sensors and Entro's endpoint coverage.

For remote MCP servers, route traffic through a gateway that checks each call. Tool poisoning, where a server's tool description hides instructions, is easier to catch when tool lists are reviewed before approval.

What should you log?

Aim for one record per agent session that a reviewer can read after an incident. At minimum, the record should hold the following.

  • Developer, machine and agent tool, with version.
  • Repository and branch the session worked in.
  • Shell commands run, with exit status.
  • MCP servers and tools called, with arguments where safe to store.
  • Credentials or tokens requested during the session.
  • Commits, pull requests and comments the agent created.

How do you roll out controls?

  1. Inventory which coding agents are in use, through endpoint reports and a short developer survey.
  2. Publish a list of approved agent tools and versions, and the settings each must use.
  3. Remove static cloud and production keys from developer shells. Issue short-lived credentials per session instead.
  4. Require branch protection and review for every commit, whoever or whatever wrote it.
  5. Set agent tools to ask before running shell commands outside a safe list, where the tool supports it.
  6. Publish an approved list of MCP servers and block unknown servers through endpoint policy.
  7. Route remote MCP traffic through a gateway that logs each call.
  8. Collect session logs centrally and keep them as long as your code audit records.
  9. Review the approved lists every quarter with the developer platform team.

What should developers be told?

Controls work better when developers understand them. A short note from the platform team, written in plain terms, prevents most workarounds.

  • Which agent tools and versions are approved, and how to request others.
  • That agents act with your access, so keep production keys out of your shell.
  • Which MCP servers are approved, and how to propose a new one.
  • That agent commits go through the same review as yours.
  • Where session logs go and who can read them.

Ask developers to report odd agent behaviour, such as an agent trying to read files outside the project. Those reports often catch prompt injection before any tool does.

Coding agent checklist

  • Coding agent tools inventoried and an approved list published.
  • No static production or cloud keys in developer shells.
  • Branch protection and review required for agent commits.
  • Shell commands outside a safe list need confirmation.
  • Local MCP servers reported by endpoint tooling and limited to an approved list.
  • Remote MCP calls pass a logging gateway.
  • Session records collected centrally.

What to ask your vendor

  • Can you discover coding agents and local MCP servers on endpoints, not only in the cloud?
  • Can a coding agent receive its own scoped identity, separate from the developer's?
  • Do you record shell commands and tool calls per agent session?
  • Can you block unapproved MCP servers on a laptop?
  • How do you handle agents that run offline or outside the corporate network?

For teams whose first gap is finding agents nobody registered, including local ones, the matching buyer-need ranking is linked below.

Best for finding agents nobody registered

Questions buyers ask

Do coding agents use the developer's permissions?

Usually yes. A coding agent running in a terminal or editor uses the credentials available in that session. Narrow those credentials and require review for commits, whoever wrote them.

How do I find MCP servers running on laptops?

Use endpoint tooling that reports running processes and agent configuration files. Network gateways see only remote servers, so local servers need endpoint coverage.

What should a coding agent session log contain?

Developer, machine, tool and version, repository and branch, shell commands, MCP tools called, credentials requested, and the commits or comments the agent created.

Related pages

Sources