<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Agentic DevSecOps on AWS on Matheus Costa - Cloud &amp; Platform Engineer | AWS Community Builder</title><link>https://matheuscosta.dev/series/agentic-devsecops-on-aws/</link><description>Recent content in Agentic DevSecOps on AWS on Matheus Costa - Cloud &amp; Platform Engineer | AWS Community Builder</description><image><title>Matheus Costa - Cloud &amp; Platform Engineer | AWS Community Builder</title><url>https://i.imgur.com/sfKaH9W.jpeg</url><link>https://i.imgur.com/sfKaH9W.jpeg</link></image><generator>Hugo -- 0.152.2</generator><language>en</language><lastBuildDate>Tue, 10 Nov 2026 10:00:00 -0300</lastBuildDate><atom:link href="https://matheuscosta.dev/series/agentic-devsecops-on-aws/index.xml" rel="self" type="application/rss+xml"/><item><title>What an AI Agent With AWS Credentials Can Break: A Threat Model</title><link>https://matheuscosta.dev/posts/2026/11/ai-agent-aws-credentials-threat-model/</link><pubDate>Tue, 10 Nov 2026 10:00:00 -0300</pubDate><guid>https://matheuscosta.dev/posts/2026/11/ai-agent-aws-credentials-threat-model/</guid><description>Kiro, Amazon Q and MCP servers run with your AWS credentials. A practical threat model: what an agent can break, how it happens and which controls hold.</description><content:encoded><![CDATA[<h2 id="introduction">Introduction</h2>
<p>AI agents stopped being chat windows. Kiro CLI, Amazon Q and MCP servers like <code>awslabs.aws-api-mcp-server</code> run AWS CLI calls and shell commands on your machine, with whatever credentials your terminal has. In many teams, that means the engineer&rsquo;s own SSO session, often with admin rights.</p>
<p>This post is part 1 of the series <strong>Agentic DevSecOps on AWS</strong>. Here I map what can go wrong. Part 2 builds the IAM guardrails, and part 3 builds the detection.</p>
<h2 id="quick-answer">Quick Answer</h2>
<p>An AI agent inherits <strong>every permission of the credential it runs with</strong>, and its client-side settings are not a security boundary: an agent that can run a shell can call <code>aws</code> directly. The risks fall into five groups: destructive mistakes, prompt injection, data exposure, privilege escalation and cost. The controls that hold are the ones enforced by AWS: a <strong>dedicated, short-lived role per agent session</strong>, a <strong>permission boundary</strong>, <strong>attribution in CloudTrail</strong> and <strong>detection on agent activity</strong>.</p>
<h2 id="how-an-agent-actually-touches-your-account">How an agent actually touches your account</h2>
<p>There are three paths, and they matter because each one has different controls:</p>
<table>
  <thead>
      <tr>
          <th>Path</th>
          <th>Example</th>
          <th>Credential used</th>
          <th>Client-side control</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Native AWS tool</td>
          <td>Kiro CLI <code>aws</code> tool (<code>use_aws</code>)</td>
          <td>Current profile / env</td>
          <td><code>allowedServices</code>, <code>deniedServices</code>, <code>autoAllowReadonly</code></td>
      </tr>
      <tr>
          <td>Shell</td>
          <td>Agent runs <code>aws ec2 terminate-instances ...</code></td>
          <td>Current profile / env</td>
          <td><code>allowedCommands</code>, <code>deniedCommands</code>, <code>denyByDefault</code></td>
      </tr>
      <tr>
          <td>MCP server</td>
          <td><code>awslabs.aws-api-mcp-server</code></td>
          <td><code>AWS_API_MCP_PROFILE_NAME</code> or default chain</td>
          <td><code>READ_OPERATIONS_ONLY</code>, <code>REQUIRE_MUTATION_CONSENT</code></td>
      </tr>
  </tbody>
</table>
<p>The trap is in the second row. You can deny <code>iam</code> in the AWS tool and the agent can still run <code>aws iam create-access-key</code> through the shell. And the shell allowlist is regex matching on a command string, which the Kiro docs themselves warn can be bypassed with things like a variable assignment before the command.</p>
<p>Client-side settings are good for <strong>reducing prompts and accidents</strong>. They are not where you enforce security.</p>
<h2 id="the-threat-model">The threat model</h2>
<p>I use five categories. For each one: how it happens with an agent, the impact and the control that actually holds.</p>
<h3 id="1-destructive-mistakes-no-attacker-needed">1. Destructive mistakes (no attacker needed)</h3>
<p>The most likely failure isn&rsquo;t malicious. The agent misreads the task, picks the wrong account or region, or &ldquo;cleans up&rdquo; resources it thinks are unused.</p>
<ul>
<li><strong>Vector:</strong> ambiguous prompt, wrong <code>AWS_PROFILE</code>, auto-approved commands, long sessions where the context drifts.</li>
<li><strong>Impact:</strong> deleted buckets, terminated instances, dropped tables, broken networking.</li>
<li><strong>Control that holds:</strong> a permission boundary that denies irreversible actions (<code>s3:DeleteBucket</code>, <code>rds:DeleteDBInstance</code>, <code>kms:ScheduleKeyDeletion</code>, &hellip;) and allows terminating only resources tagged as agent-managed.</li>
</ul>
<h3 id="2-prompt-injection">2. Prompt injection</h3>
<p>The agent reads untrusted content (a README, a GitHub issue, a log line, an S3 object, a web page) that contains instructions. It treats them as part of the task.</p>
<ul>
<li><strong>Vector:</strong> anything the agent reads during the session. You don&rsquo;t need a compromised machine, only a poisoned input.</li>
<li><strong>Impact:</strong> the attacker effectively gets your agent&rsquo;s permissions.</li>
<li><strong>Control that holds:</strong> assume injection will eventually happen and limit what a hijacked session can do. Least privilege on the role, no secret reads, approved regions only, and an alert on every write call.</li>
</ul>
<h3 id="3-data-exposure">3. Data exposure</h3>
<p>The agent needs to <em>see</em> configuration. It rarely needs to read <em>data</em>. But the managed policy most people grab for &ldquo;read-only&rdquo;, <code>ReadOnlyAccess</code>, includes <code>s3:GetObject</code>, DynamoDB reads and more.</p>
<ul>
<li><strong>Vector:</strong> an agent dumping objects, table items or parameters into its context, which then goes to a model provider or into a log.</li>
<li><strong>Impact:</strong> customer data or secrets leaving the account through the model context.</li>
<li><strong>Control that holds:</strong> use <code>ViewOnlyAccess</code> (configuration, not content) for the read-only role, and explicitly deny <code>secretsmanager:GetSecretValue</code>, <code>ssm:GetParameter*</code> and <code>kms:Decrypt</code> in the boundary.</li>
</ul>
<h3 id="4-privilege-escalation-and-persistence">4. Privilege escalation and persistence</h3>
<p>If the agent&rsquo;s role can change IAM, a single injected instruction becomes a permanent backdoor: a new access key, a new user or a role with a trust policy pointing outside.</p>
<ul>
<li><strong>Vector:</strong> <code>iam:CreateAccessKey</code>, <code>iam:AttachRolePolicy</code>, <code>iam:PassRole</code>, <code>iam:UpdateAssumeRolePolicy</code>.</li>
<li><strong>Impact:</strong> persistence that survives the session and the investigation.</li>
<li><strong>Control that holds:</strong> the boundary denies every mutating IAM action, plus SSO, Identity Store and Organizations. Agents don&rsquo;t manage identity. Humans do, through Terraform and review.</li>
</ul>
<h3 id="5-defense-evasion-and-cost">5. Defense evasion and cost</h3>
<p>A hijacked or confused agent can turn off the things that would catch it (CloudTrail, GuardDuty, Security Hub, the detection rule itself) or simply spin up expensive resources.</p>
<ul>
<li><strong>Vector:</strong> <code>cloudtrail:StopLogging</code>, <code>guardduty:DeleteDetector</code>, <code>events:DisableRule</code>, large instance types in a forgotten region.</li>
<li><strong>Impact:</strong> blind spots, and a bill.</li>
<li><strong>Control that holds:</strong> deny tampering with logging and with the agent detection pipeline, deny every region you don&rsquo;t use, and keep budget alerts.</li>
</ul>
<h2 id="attribution-the-control-everyone-skips">Attribution: the control everyone skips</h2>
<p>When something goes wrong, the first question is <em>who did this, the engineer or the agent?</em> If the agent uses the engineer&rsquo;s SSO session, CloudTrail can&rsquo;t tell you.</p>
<p>The fix is cheap: the agent assumes a dedicated role with a session name that identifies it, for example <code>agent-kiro-matheus</code>. Every event then carries:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">arn:aws:sts::111122223333:assumed-role/ai-agent-operator/agent-kiro-matheus
</span></span></code></pre></div><p>That one string lets you search, alert and revoke only agent sessions. Part 2 enforces this in the trust policy (<code>sts:RoleSessionName</code> must start with <code>agent-</code>).</p>
<h2 id="the-control-stack-in-order-of-importance">The control stack, in order of importance</h2>
<ol>
<li><strong>Dedicated, short-lived role per agent session.</strong> Never the human&rsquo;s session.</li>
<li><strong>Permission boundary.</strong> No IAM, no defense evasion, no irreversible deletes, no secrets, approved regions only.</li>
<li><strong>Least-privilege identity policy.</strong> <code>ViewOnlyAccess</code> by default, operator permissions only when the task needs them.</li>
<li><strong>Attribution.</strong> Session name <code>agent-*</code>, enforced by the trust policy.</li>
<li><strong>Detection and response.</strong> Alert on every write from an agent session, and be able to revoke all agent sessions in one step.</li>
<li><strong>Client-side settings.</strong> <code>deniedServices</code>, <code>READ_OPERATIONS_ONLY</code>, <code>REQUIRE_MUTATION_CONSENT</code>. Useful, never sufficient.</li>
</ol>
<h2 id="common-issues">Common Issues</h2>
<h3 id="but-i-approve-every-command">&ldquo;But I approve every command&rdquo;</h3>
<p><strong>Problem:</strong> approval fatigue. After the twentieth prompt you approve without reading, and <code>autoAllowReadonly</code> plus broad allowlists remove the prompts anyway.
<strong>Solution:</strong> approvals are UX. Put the limits in IAM, where they don&rsquo;t depend on your attention.</p>
<h3 id="the-mcp-server-is-read-only">&ldquo;The MCP server is read-only&rdquo;</h3>
<p><strong>Problem:</strong> <code>READ_OPERATIONS_ONLY=true</code> is enforced by the server, on its own tool calls. The same agent may also have a shell.
<strong>Solution:</strong> give the MCP server a read-only <em>profile</em> (<code>AWS_API_MCP_PROFILE_NAME=agent-readonly</code>), so the limit lives in IAM.</p>
<h2 id="whats-next">What&rsquo;s next</h2>
<p>In <strong>part 2</strong> I build the two agent roles (read-only and operator), the permission boundary and the trust policy in Terraform, and show the guardrail denying an IAM change. The Terraform module and the policies will be published as an open-source repository together with part 2.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://kiro.dev/docs/reference/built-in-tools/">Kiro CLI — built-in tools and <code>toolsSettings</code></a></li>
<li><a href="https://awslabs.github.io/mcp/servers/aws-api-mcp-server">AWS API MCP Server — security settings</a></li>
<li><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">IAM permissions boundaries</a></li>
<li><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html">AWS managed policies for job functions (ViewOnlyAccess)</a></li>
<li><a href="https://genai.owasp.org/llmrisk/llm01-prompt-injection/">OWASP Top 10 for LLM Applications — Prompt Injection</a></li>
</ul>
]]></content:encoded></item></channel></rss>