Insights · November 2026

Securing AI coding agents on a small team

Seven practical controls for companies using AI coding assistants and MCP servers, without slowing developers down.

By Kaleb Hasselstrom, Principal, Kastle Solutions

AI coding agents have moved from autocomplete to tools that read a whole repository, run shell commands, call APIs, and open pull requests. For a small team that is a real productivity gain. It also means a piece of software that takes instructions from text now has the same access as your developers.

You don't need a new security program to use these tools safely. The controls below are the ones you would apply to any new user with broad access, adapted for an agent. Most can be set up in an afternoon with the settings your tools already have.

  1. 01

    Give the agent its own, smaller set of permissions

    A coding agent runs with whatever access the developer's session has: their cloud CLI logins, SSH keys, package-registry tokens, and admin rights on the laptop. That is far more than it needs to edit code in one repository. If the agent is tricked or simply wrong, it can do anything you can.

    What to do: Run agents in a container, dev container, or VM that holds only the repository and the tools it needs. Don't run them from an account that has standing production or admin access. Where an agent needs cloud access, give it a separate identity with a narrow role.

  2. 02

    Keep secrets out of its reach

    Agents read files to understand a project, and .env files, local config, and shell history often hold live keys. Anything the agent reads can end up in its context, in a log, or in a command it runs.

    What to do: Move secrets into a secrets manager and inject them at runtime. Use short-lived, narrowly scoped tokens (for example, fine-grained repository tokens instead of account-wide ones). Use your tool's deny rules to block reads of secret files, and rotate anything that has already been exposed to an agent session.

  3. 03

    Require approval for commands that change things

    Most agents can run shell commands. Auto-approving everything is convenient until the agent deletes a directory, force-pushes, or runs a migration against the wrong database.

    What to do: Allow read-only and build or test commands without prompting, and require a human to approve anything destructive or outward-facing: deletes, pushes to protected branches, deployments, package publishing, and infrastructure changes. Never give an agent unattended access to production.

  4. 04

    Restrict where it can send data

    An agent with open internet access can be steered into sending data out, sometimes as innocently as fetching a URL that has your data in the query string. Open egress also lets it pull and run code from anywhere.

    What to do: Limit outbound traffic to an allow-list: your Git host, package registries, the model provider, and documentation sites you trust. Log what the agent fetches. Most corporate proxies and container runtimes can enforce this without new tooling.

  5. 05

    Vet MCP servers and plugins like dependencies

    Model Context Protocol (MCP) servers and agent plugins give the model new tools, and each one is code that runs with your permissions, often with an OAuth grant to a SaaS account. A tool's own description is read by the model, so a malicious or compromised server can also carry instructions.

    What to do: Keep an inventory of the servers and plugins your team uses. Prefer ones from the vendor of the system they connect to, pin versions, read the source or permissions before installing, and grant the narrowest OAuth scopes offered. Remove the ones nobody uses.

  6. 06

    Treat everything the agent reads as untrusted

    Prompt injection is the agent-era version of untrusted input. Text in an issue, a README, a web page, a dependency's docs, or a pull request comment can contain instructions the model may follow. The agent cannot reliably tell your request apart from text it was asked to read.

    What to do: Assume any content from outside your team may try to redirect the agent. That is why the controls above matter: limited permissions, no secrets in reach, approval for risky commands, and restricted egress keep a successful injection from turning into an incident. Be most careful when an agent works on public repositories or reads external tickets.

  7. 07

    Keep a human in the change path, and keep logs

    Agent-written code is still code your company ships. Change management controls that auditors already expect (peer review, protected branches, CI) apply just as much when the author is a model.

    What to do: Require pull requests and human review for agent changes to protected branches, keep CI checks mandatory, and make agent commits identifiable. Keep the agent's session or command logs long enough to answer "what did it run, and when" after the fact.

Write it down

Put these decisions in a one-page AI tool policy: which agents and MCP servers are approved, what they may access, which actions need approval, and where logs live. If you are working toward SOC 2 or ISO 27001, that page and the settings behind it become evidence for the access control and change management controls your auditor will already test.

Know your gaps before your auditor does.

Tell us your audit date and how your Microsoft 365 environment is set up. We respond within one business day.