Software Factory Security: How to Secure a Fleet of AI Coding Agents

- Share:





3366 Members
TL;DR: A software factory is a fleet of coding agents (Claude Code, Cursor, Codex, cloud and background agents) that write, test and ship code while humans approve at checkpoints. Securing it means giving every agent its own identity delegated from a human and scoped to the task, denying by default, checking every tool call against policy outside the model, putting a human approval on merge, deploy, secrets and production data, and keeping one decision log as the factory's audit trail. Enforce that same policy at the endpoint, at the tool layer, and in your apps, APIs and data.
"Software factory" used to mean CI pipelines and golden paths. For platform and security teams in 2026, software factory security means governing fleets of AI coding agents. A ticket lands, an agent picks it up, a second agent writes tests, a third reviews, and a human clicks merge. Teams increasingly run many of these loops in parallel. The output is real code in real repos, deployed to real customers.
The security model under most of these factories hasn't changed since the agents were autocomplete. They run as the developer, with the developer's tokens, and nothing in between asks whether a given action should happen. That gap is what this post is about, and it closes with a checklist and an adoption path a platform or security lead can start on this quarter.
Every coding agent in the factory is a privileged process. It holds shell access, credentials and outbound network reach, and it acts at machine speed. Five problems show up again and again.
.env files. Nothing scopes those to the ticket the agent is working on.Sandboxes help with the blast radius of code execution, but they don't decide what an agent is allowed to do with the credentials it holds. We covered that gap in coding agent sandboxes don't solve credential authorization.
The fix is the same access control discipline we already apply to people, applied per agent, per call.
An agent identity in a factory is composite. It binds the human who delegated the work, the client the agent runs as, the workflow it is executing, and the intent it declared. A grant is a relationship: human to agent to action to resource. When you revoke the human or change their role, every agent acting for them loses that access on its next call, with no token hunt.
This is how Permit MCP Gateway models it. As shared in our docs, an agent is identified by the OAuth client ID it registers with, and revoking a human's access cascades to all of their agents for that server. For the longer argument on why service accounts don't fit, read agent identity vs service accounts.
Start every agent with nothing. Allow known destinations, tools and paths explicitly. This is firewall logic applied to a new class of process, and it is the only baseline that holds up when the agent is manipulated. A factory agent assigned a dependency bump has no reason to read ~/.aws/credentials or post to a paste site.
Guardrails in the prompt are suggestions. The decision has to come from a policy engine the model can't talk to. Every outbound call from the agent process, every MCP tool call and every protected API call gets a check: may this agent, acting for this human, in this workflow, do this action on this resource right now?
Intent belongs in that check. Ask the agent what it is trying to do, then compare later calls with that declaration. When behavior drifts from the stated intent, policy can downgrade trust, ask for consent again or block. We went deeper on this in agentic intent and AI agent drift.
The factory works because humans stay at a few checkpoints and stay out of everything else. Put approvals on:
Approval has to be configurable or it turns into rubber stamping. In Permit MCP Gateway, as shared in our docs, human-in-the-loop approvals can trigger on a trust level threshold or on specific tools, hold the call as pending until an admin decides, notify admins by email or Slack, reject on timeout, and let named agents such as CI bots or scheduled pipelines bypass approval. That's how factory runs avoid drowning in approval prompts while the dangerous paths still stop for a person. Human-in-the-loop approvals are on Enterprise plans.
Every allow and deny gets recorded with the human, the agent, the tool or destination, the time and the reason. That record answers the questions auditors and incident responders will ask: who delegated this, what did the agent try, and why was it allowed. Make it API first so it lands in the SIEM and observability stack you already run. See the human to agent delegation audit trail for the fields that matter.
A prompt injection that slips past one check should still meet the next. In a factory, an agent action crosses several layers, and each one should ask its own question of the same identity and the same policy.
| Layer | What it governs | The question it asks |
|---|---|---|
| Endpoint and process | Outbound HTTP calls from coding agent processes | May this agent process reach this destination with this payload? |
| Tool (MCP and SaaS) | MCP servers and the SaaS behind them | May this agent call this tool, with these arguments, for this human? |
| API | Internal and external endpoints | May this delegated token reach this endpoint? |
| Application | Business actions inside your product | May this user approve this record in this tenant? |
| Data | Databases and warehouses the agents query | May this query read this column or row? |
Permit maps onto this as one chain of control:
All three share the same identities, policies and audit chain. The MCP side of this connects to standards work too: MCP Enterprise-Managed Authorization explains how enterprise IdPs issue access to MCP servers, and OAuth on MCP covers the client registration flows underneath.
Here is the checklist we'd hand a platform or security lead running a software factory.
Identity
Policy
Checkpoints
Evidence
The snippet below is an example written for this post, not a shipped policy. It shows the shape of the rule: deny by default, allow scoped actions inside the agent's workflow, and route risky actions to a human.
# Illustrative example only.
package factory.agents
default decision := "deny"
risky_actions := {"merge_protected", "deploy_prod", "read_secret", "query_prod_data", "publish_package"}
# Scoped work inside the delegated workflow runs without a prompt
decision := "allow" if {
input.agent.delegated_by == input.human.id
input.action in data.workflows[input.agent.workflow].allowed_actions
not input.action in risky_actions
input.agent.intent_matches
}
# Risky checkpoints always go to a human
decision := "require_approval" if {
input.agent.delegated_by == input.human.id
input.action in risky_actions
input.agent.intent_matches
}
If you already use Permit in code, the same question is a single check with the agent as the subject, for example permit.check("agent|ci-fixer", "merge", "repo:payments-api"), with the delegating human and the workflow modeled as relationships.
This is the path I recommend when teams ask where to start. It gets you to a controlled pilot quickly without making approvals the bottleneck.
On deployment: as shared in our docs, Permit MCP Gateway runs hosted, customer-controlled or fully on-premises. Customer-controlled keeps the gateway and a local PDP in your network while Permit hosts the control plane. Fully on-premises runs the whole stack in your environment with no internet connection required, which fits an air-gapped "dark factory." Both are on Enterprise plans. The hosted gateway is the quickest way to start, at agent.security.
Everything above governs agents that route through your controls. A software factory also attracts agents nobody registered: a developer's side experiment, a new CLI someone installed last week, an MCP server added with a one line JSON edit. You can't govern agents you can't see. Endpoint enforcement scoped to agent processes narrows that gap, and the industry still has work to do here. If you run a factory, inventory your agents before you write your first policy.
For the security team's view of all this, start at Permit for security teams. For how trust levels map to commands and tools, read trust levels for coding agents.
A software factory is a setup where fleets of AI coding agents write, test and ship code, with humans approving at checkpoints such as merge and deploy. Agents run in IDEs, CLIs, CI and cloud background jobs.
Agents run with broad human or standing credentials while reading untrusted content. A prompt injection in an issue or README can turn that access into data exfiltration or a destructive change, and without per-agent identity nobody can tell which agent did it.
Sandboxes limit where code runs. They don't decide which credentials, tools and destinations an agent may use for a given task. You need identity and a per-call policy check on top.
On actions that are hard to undo: merging to protected branches, production deploys, secret access, production data and package publishing. Everything else should run on trust levels and allowlists so approvals stay meaningful.
Log every policy decision with the human, the agent, the action, the resource, the outcome and the reason, and send it outside the agent's reach to your SIEM. That log is the factory's audit trail.

Co-Founder / CEO at Permit.io