Skip to navigation

Claude Code Threat Models: Infrastructure Agent Boundaries

In short: Map assets, identities, trust boundaries and failure paths before allowing Claude Code to operate cloud and Kubernetes systems.

Published 17 min read
On this page

Direct answer

Threat model Claude Code’s infrastructure access by starting from what the agent’s credentials can actually reach, then working outward to assets, trust boundaries and failure paths. Do not start from prompt injection. An AI coding agent can modify application code, CI/CD configuration, package scripts and deployment infrastructure, so the useful model follows the agent’s permissions all the way to the cloud or Kubernetes asset it can change. A model that stops at the repository misses the control plane.

The concrete win is a threat model that names the specific infrastructure an incident could reach, which makes blast radius a planning input instead of a discovery. The concrete loss is that permission models are additive, so effective access is broader than any single role suggests and the model has to be revisited whenever bindings change. The practical implication is that sandboxing limits where commands run, not what the agent’s identity can do. Sandboxing and identity controls answer different questions and neither substitutes for the other.

The method below walks through eight sections: scope the assets, inventory the agent identities, draw the trust boundaries, trace the untrusted output paths, then model the cloud control plane, the Kubernetes control plane, the failure cases, and finally the controls against residual risk.

System and Asset Scope

Scope is the list of assets the agent can affect, which is broader than the list of assets the agent was intended to affect. Build it from the credentials and permissions rather than from the workflow description.

Asset Agent capability Business impact
Application source repository Read and write code, including CI config Compromised builds, injected dependencies
CI/CD pipeline definition Modify build and deploy steps Deployment of unreviewed code
Cloud resource group or subscription Create, modify, delete resources Data exposure, cost impact, outage
Kubernetes cluster namespaces Apply workloads and configuration Workload compromise, lateral movement
Secrets and credentials stores Read or write depending on scope Credential theft, account takeover
Observability stack Modify dashboards, alerts, log sinks Lost detection, hidden evidence

Two rows are commonly underestimated. The CI/CD row is a high-value target because a change there executes automatically, and the observability row matters because an agent that can modify its own alerting can hide its own activity. OWASP’s secure coding guidance for AI explicitly names CI/CD configuration and deployment infrastructure among the things agents can modify, which is the reason the scope table has to include them.

Write the scope down and date it. The scope changes whenever the agent’s identity changes, which is the same trigger that drives an off-cycle access review in the access recertification guide for agent identities.

Independent, F052: OWASP Secure Coding with AI guidance states that AI coding agents can modify application code, CI/CD configuration, package scripts and deployment infrastructure. This broadens threat-model scope but does not establish any specific vulnerability in Claude Code.

Agent Identities

Every capability in the scope table comes from an identity, so inventory the identities before modeling anything else. An agent that shares a human identity has the human’s reach, and that is a scope decision that has to be made deliberately rather than inherited.

Identity What it can reach Why it exists
Agent deployment service account Read registry, deploy to staging Routine release workflow
Agent CI identity Trigger pipelines, write deploy config Automated delivery
Shared human identity Whatever the developer can reach Legacy setup, candidate for separation
Break-glass identity Broad, gated Incident response

The shared-identity row is the finding to act on. Separating the agent onto its own identity is the single change that makes every other control in this post measurable, because it turns “what can the team do” into “what can the agent do”. The cloud IAM permission boundary review guide covers reviewing the boundary around that identity once it exists.

Official, F053: Claude Code uses permission modes and sandboxing for isolation, with managed settings available to administrators. These are product-level controls around where commands run and what the tool asks before acting. They do not define the cloud identity’s reach, which is yours to scope.

Trust Boundaries

A trust boundary is a line where data or instructions cross from a less-trusted context to a more-trusted one. Infrastructure threat models for agents have more of these lines than most teams draw, because agent output crosses several on its way to a production change.

Trust boundary What crosses it Expected control Verification evidence
Repository content to agent Instructions and code the agent reads Treat as untrusted input Prompt-injection test cases, review of CLAUDE.md
Agent output to human reviewer Proposed changes and commands Human review before apply Review record per change
Agent action to CI system Commits and pipeline triggers Branch protection, required review Branch protection configuration
CI system to cloud control plane Deploy credentials Scoped deployment identity Identity scope export
Agent to Kubernetes API Applied manifests RBAC scoped to intended namespaces Binding enumeration

The first row is where agent-specific threat modeling starts, and it is also where models usually stop. Repository content is untrusted because it can arrive from a pull request, a dependency, or a file someone committed without review. The repository prompt injection guide covers that path in detail, and the repository hooks security guide covers trust boundaries and fail-closed behavior for hooks.

The last two rows are where infrastructure threat modeling earns its keep. A scoped deployment identity and namespace-scoped RBAC are the controls that limit how far a compromised agent action travels, and the Kubernetes RBAC least privilege guide covers narrowing them.

Evidence map tracing the agent's permissions from repository access through CI and cloud or Kubernetes identities to the specific infrastructure assets they can change.
Editorial evidence map based on F052 to F054. The useful threat model follows the agent’s permissions all the way to the infrastructure asset, not just the prompt. Labels are the post author’s.

Untrusted Output Paths

Agent output is untrusted input to everything downstream that acts on it. Tracing the paths that output takes is how you find the boundaries an attacker would try to cross.

Output path Downstream actor Failure if wrong
Proposed code change Human reviewer, then compiler Vulnerable or malicious code merged
Proposed Terraform change Reviewer, then plan and apply Infrastructure modified or destroyed
Suggested dependency Package manager Supply-chain compromise
Suggested command Operator who runs it Arbitrary execution with operator privileges
Generated manifest Kubernetes API Workload with excessive privileges

The command row deserves specific attention. A suggested command copied into a terminal runs with the operator’s privileges, which are usually broader than the agent’s. Treating agent-suggested commands as untrusted input, and reviewing them with the same care as a code change, is the control for that path.

The dependency row is covered by the hallucinated packages guide, and the plugin security audit guide covers the case where the thing being suggested is a hook or command rather than a package.

Every path in that table crosses a trust boundary from the previous section, which is the point of tracing them. A boundary without a control is a finding, and the model exists to name those findings before an incident names them for you.

Cloud Control Plane

The cloud control plane is where the agent’s reach becomes infrastructure change. Model it by asking which API actions the agent’s identity can perform, on which resources, and what each one would mean if performed wrongly.

Cloud capability Failure case Mitigation Residual risk
Modify security groups Open ingress to a database Permission boundary excluding security groups Remaining actions still need review
Create IAM roles Privilege escalation path Deny iam:CreateRole outside a path Existing roles still exploitable if compromised
Modify storage policies Public exposure of data Boundary limiting storage policy scope Data already public stays public
Delete resources Outage or data loss Delete protection, backups Recovery time still applies
Modify logging configuration Hidden activity Deny on log destination changes Prior logs may be incomplete

Official, F054 context: Kubernetes RBAC grants additive permissions, and the same union principle applies on the cloud side. Effective access has to be evaluated across all applicable roles and policies, and a review of one edited role does not establish the identity’s complete reach.

The permission boundary is the control that most changes the shape of this table. A boundary that excludes the highest-impact actions, such as IAM role creation and log destination changes, reduces the worst-case outcomes more than any amount of review. The IAM permission boundary review guide covers designing and reviewing that boundary.

Cost is a side effect worth modeling too. An agent that can create resources can create expensive ones, and the cloud budget and quota guardrails guide covers the budget and quota controls that bound that failure.

Kubernetes Control Plane

The Kubernetes control plane has its own boundaries, and the additive RBAC model means the agent’s effective access is the union of every binding that applies to it.

Kubernetes capability Failure case Mitigation Residual risk
Apply privileged workloads Container escape path Pod Security admission controls Kernel vulnerabilities remain
Read secrets cluster-wide Credential theft Namespace-scoped secret access Namespaced secrets still readable
Modify RBAC bindings Self-granted cluster access Deny RBAC escalation Existing bindings still apply
Modify network policies Lateral movement Default-deny policies, reviewed Existing connections may persist
Apply to hostPath or hostNetwork Node compromise Admission control rejecting host access Node-level controls still needed

Official, F054: Kubernetes RBAC grants additive permissions with no deny rules in the RBAC model, so effective access must be evaluated across all applicable roles and bindings. Reviewing one edited Role or ClusterRole does not establish the identity’s complete effective access.

The cluster-scoped binding is the row to look for first. An agent identity with a cluster-scoped role has reach across every namespace, which makes namespace isolation meaningless for that identity. Scoping to the intended namespaces is usually the highest-value change available, and the Kubernetes RBAC least privilege guide covers it.

Network boundaries are the second control layer. The NetworkPolicy blast radius guide covers reviewing how far a compromised workload can reach, and the Kubernetes Network Policies documentation in the sources is the reference for what policies can express. The pod security admission gates guide covers the workload-level controls in the privileged-workload row.

Workflow from scoping assets and identities through drawing trust boundaries, modeling cloud and Kubernetes control planes, and mapping failure cases to controls.
Editorial workflow derived from F052 to F054. The sequence describes a reviewable routine; it is not an official threat-modeling standard.

Failure and Abuse Cases

Failure cases cover what happens when the agent is wrong. Abuse cases cover what happens when something directs the agent deliberately. Both belong in the model, and they produce different controls.

Failure or abuse case Existing mitigation Residual risk owner
Agent proposes a destructive apply Plan review before apply Change approver
Agent follows instructions from repository content Prompt-injection review, untrusted-input handling Platform team lead
Compromised agent credential Credential rotation, scoped identity Identity owner
Agent modifies its own alerting Deny on observability mutation Observability owner
Agent exfiltrates repository content Data boundaries, egress control Security reviewer
Agent suggested command run by operator Operator review discipline Operator, with platform support

The abuse rows are where the trust boundary from repository content to agent matters most. An agent with production reach that can be directed by repository content is a chain worth modeling explicitly rather than dismissing as unlikely. The prompt injection guide covers the mechanism, and the security research refusals guide covers how the tool behaves when asked to do something harmful, which is relevant context but not a control.

The destructive-apply row is the one with the clearest control. A plan review gate that requires a human to read the plan before apply is the single most effective mitigation for infrastructure failure cases, and the Terraform plan review gates guide covers building it. State access controls matter alongside it, which the Terraform state access controls guide covers, and drift has to be triaged before reconciliation, which the Terraform drift triage guide covers.

Tradeoff between broad agent reach that speeds up infrastructure work and the blast radius that reach creates when something goes wrong.
Editorial tradeoff diagram based on F052 to F054. Broader reach speeds up infrastructure work and widens the blast radius of any failure or abuse case.

Control and Residual Risk Map

The final section maps each failure case to a control and names who owns the risk that remains. A threat model without a residual-risk owner is a document, not a decision.

Boundary or failure case Control in place Residual risk owner
Repository content to agent Untrusted-input handling, injection review Platform team lead
Agent action to cloud control plane Permission boundary, plan review Change approver
Agent action to Kubernetes Namespace-scoped RBAC, admission controls Cluster admin
Agent credential compromise Rotation schedule, scoped identity Identity owner
Observability mutation Deny on log destination changes Observability owner
Operator runs suggested command Review discipline, least-privilege operator identity Operator with platform support

Two properties make the map honest. Every residual risk has a named owner who accepted it, which is the same accountability the RACI ownership guide for infrastructure changes applies to change roles. And the map records what is not controlled, because a model that shows only mitigations hides the cases a reader most needs to know about.

Where a control is missing and the team has decided to accept the exposure, record it as an exception with an owner and an expiry, per the security exception ownership guide. Where the model reveals requirements the team cannot evidence, the AISVS control mapping guide is the framework for tracking them to closure.

Control checklist covering asset scope, identity separation, trust boundaries, untrusted output paths, control-plane boundaries, failure cases and named residual risk owners.
Editorial control checklist derived from F052 to F054. Passing the checklist shows the model was produced honestly; it does not guarantee the infrastructure is safe.

The concrete win, loss, and implication

The concrete win is a blast radius you can state. When the model traces the agent’s identity to the specific resources it can change, an incident plan can be built against named assets rather than against “the agent has some cloud access”. Approvals get faster too, because a reviewer can see what a proposed change could reach.

The concrete loss is that the model decays with the permissions. Additive RBAC and changing cloud policies mean the union of effective access shifts whenever a binding is added, so the model is a snapshot with a maintenance cost. A model produced once and never revisited is worse than none, because it creates false confidence.

The practical implication is that sandboxing and identity controls are complementary, not interchangeable. Sandboxing limits where commands run and what the tool does by default. Identity scoping limits what the credentials behind the agent can reach. Teams that rely on one and skip the other keep discovering the gap during an incident, and the incident timeline correlation guide covers the investigation that follows.

Working through the model with Claude Code

Give the agent three inputs: the identities it may read to enumerate permissions, the repositories and configuration it may inspect, and the definition of done for the model. Ask for an enumeration of effective access per identity, a scope table of reachable assets, and a draft trust boundary list.

Useful agent outputs are the permission union per identity, a candidate asset list with the capability that reaches each one, and a draft failure-case table. Ask it to flag boundaries it cannot find a control for rather than filling those rows with plausible mitigations. Review the flags against the live configuration, because a settings file in a repository is not proof of what is deployed.

The residual-risk decisions stay human. Whether a named risk is acceptable is a decision for the risk owner, and the agent’s role is to produce the evidence that decision needs. The verification guide covers the same division of labor for code changes.

Verdict that modeling from the agent's permissions out to the infrastructure assets produces a threat model that names blast radius, unlike one that stops at prompt injection.
Editorial verdict based on F052 to F054. Start from credentials and reach, not from the prompt, and name who owns each residual risk.

Data gap and future update

No specific vulnerability in Claude Code is claimed or described here. F052 is used to establish that AI coding agents generally can modify CI/CD configuration and deployment infrastructure, which broadens threat-model scope. F053 establishes that permission modes, sandboxing and managed settings are available isolation controls that do not replace identity controls. F054 establishes the additive nature of Kubernetes RBAC.

No weaponized exploit steps are included, and the failure cases are described at the level needed to name a control and an owner. A future update could add worked examples for a specific reference architecture, but that would need an actual deployment to enumerate.

Cloud-side permission evaluation varies by provider, and this post describes the general union principle rather than provider-specific policy evaluation details. The Kubernetes side is grounded in the RBAC documentation in the sources; the cloud side is deliberately generic.

This post is the boundary-drawing entry point for the infrastructure half of the batch. The AISVS control mapping guide covers turning the findings into a tracked control register, and the vendor security review checklist guide covers the procurement review that happens before a deployment exists to threat model.

For the secrets dimension, the secrets in logs guide covers credentials that end up in transcripts and telemetry, and the settings files and secrets guide covers configuration that weakens a safeguard quietly. The change freeze emergency rules guide covers what happens when the agent’s changes have to stop during a freeze, and the break glass incident access guide covers the emergency identity in the scope table.

One AI API Key option for OpenAI-format agents

Claude Code uses an Anthropic-format route, so the One AI free model IDs are not a Claude Code model source. The packet records Claude IDs as unavailable on 2026-11-27, and nothing in this post changes that.

OpenAI-format agents have a separate path. One AI API Key offers https://api.oneaiapikey.com/v1, one key, and 46 live free IDs, which is a different client and request format rather than a workaround for Claude Code authentication. Check the free model list and eligibility notes before wiring up an agent, read the quickstart for the request shape, or estimate spend with the cost calculator.

FAQ

Why not just threat model prompt injection?

Because prompt injection is one boundary among several, and stopping there misses the control plane. An agent whose credentials can modify cloud resources is a broader problem than an agent that can be misdirected by repository content, and the model has to cover both to be useful.

Does sandboxing replace the need for identity controls?

No. Sandboxing limits where commands run and what the tool does by default. Identity scoping limits what the credentials can reach. They answer different questions, and an agent with broad identity reach behind a sandbox still has broad reach.

What is the first change to make after threat modeling?

Separate the agent onto its own identity if it shares a human one. That single change makes every other control measurable, because the model stops describing what a team can do and starts describing what the agent can do.

How do I handle the additive RBAC problem?

Enumerate the full union of bindings that apply to the identity rather than reviewing one role at a time, and re-enumerate after every change. A review of a single binding does not establish effective access.

How often should the threat model be revisited?

Whenever the agent’s identity scope changes, whenever it gains reach into new infrastructure, and on a regular cadence regardless. A model is a snapshot of the permissions, and the permissions change more often than most teams expect.

More Claude Code troubleshooting

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
Claim $10 credit →