<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AWS Safebox</title>
    <description>The latest articles on DEV Community by AWS Safebox (@aws-safebox).</description>
    <link>https://dev.to/aws-safebox</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4211916%2F892513b4-7994-41c0-ab1d-dbf60aa80ea9.png</url>
      <title>DEV Community: AWS Safebox</title>
      <link>https://dev.to/aws-safebox</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aws-safebox"/>
    <language>en</language>
    <item>
      <title>What Should Stop an AI Coding Agent From Running terraform destroy?</title>
      <dc:creator>AWS Safebox</dc:creator>
      <pubDate>Wed, 28 Oct 2026 13:00:00 +0000</pubDate>
      <link>https://dev.to/aws-safebox/what-should-stop-an-ai-coding-agent-from-running-terraform-destroy-3h80</link>
      <guid>https://dev.to/aws-safebox/what-should-stop-an-ai-coding-agent-from-running-terraform-destroy-3h80</guid>
      <description>&lt;p&gt;AI coding agents are becoming increasingly capable of doing more than generating code.&lt;/p&gt;

&lt;p&gt;They can open terminals, execute commands, modify infrastructure-as-code, interact with cloud environments, and perform tasks that previously required a human engineer sitting at a keyboard.&lt;/p&gt;

&lt;p&gt;That creates an interesting security question.&lt;/p&gt;

&lt;p&gt;If an AI agent is allowed to execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;what prevents the same agent from executing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The obvious answer is permissions.&lt;/p&gt;

&lt;p&gt;An agent should only have access to the permissions it actually needs.&lt;/p&gt;

&lt;p&gt;That's absolutely true.&lt;/p&gt;

&lt;p&gt;But I think there is another useful layer to consider: &lt;strong&gt;a deterministic enforcement boundary between an AI agent and infrastructure tools.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of relying exclusively on the agent to decide whether a command is appropriate, what if commands were independently evaluated before execution?&lt;/p&gt;

&lt;p&gt;That's the question I've been exploring with a small open-source proof of concept called &lt;strong&gt;AWS SafeBox&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem isn't that AI agents are malicious
&lt;/h2&gt;

&lt;p&gt;The interesting threat model here isn't necessarily an attacker controlling an AI agent.&lt;/p&gt;

&lt;p&gt;Consider a perfectly legitimate engineering task.&lt;/p&gt;

&lt;p&gt;An engineer asks an agent to investigate a Terraform configuration, correct a problem, and validate the result.&lt;/p&gt;

&lt;p&gt;The agent may have access to tools such as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform
aws
kubectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most of the commands it might execute are harmless:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan
aws ec2 describe-instances
kubectl get pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the same tools expose destructive operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform destroy

aws ec2 terminate-instances &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--instance-ids&lt;/span&gt; i-xxxxxxxx

aws rds delete-db-instance &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--db-instance-identifier&lt;/span&gt; production-db

aws s3 &lt;span class="nb"&gt;rm &lt;/span&gt;s3://production-data &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--recursive&lt;/span&gt;

kubectl delete namespace production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference between those two groups of commands is enormous.&lt;/p&gt;

&lt;p&gt;Yet from the perspective of the agent, they're all simply commands available in its environment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just ask the AI whether the command is safe?
&lt;/h2&gt;

&lt;p&gt;One possible approach is to put another AI decision in the path.&lt;/p&gt;

&lt;p&gt;The agent proposes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another model evaluates the command and decides whether it should execute.&lt;/p&gt;

&lt;p&gt;That could certainly provide useful context.&lt;/p&gt;

&lt;p&gt;But for some controls, I prefer something considerably less intelligent.&lt;/p&gt;

&lt;p&gt;A deterministic policy.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform plan       -&amp;gt; ALLOW
terraform destroy    -&amp;gt; BLOCK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is no probability involved.&lt;/p&gt;

&lt;p&gt;There is no prompt interpretation.&lt;/p&gt;

&lt;p&gt;There is no model deciding that perhaps destroying the environment is appropriate given the conversation.&lt;/p&gt;

&lt;p&gt;The policy simply says that this operation isn't permitted.&lt;/p&gt;

&lt;p&gt;This isn't a replacement for IAM, operating-system controls, sandboxing, approvals, or other security mechanisms.&lt;/p&gt;

&lt;p&gt;It's another possible layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a small proof of concept
&lt;/h2&gt;

&lt;p&gt;I built AWS SafeBox to experiment with this idea.&lt;/p&gt;

&lt;p&gt;It's an open-source Python project that places a policy-checking layer in front of infrastructure command-line tools.&lt;/p&gt;

&lt;p&gt;The basic model looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AI coding agent
       |
       v
SafeBox execution boundary
       |
       v
Deterministic policy evaluation
       |
       +------ ALLOW ------&amp;gt; Real CLI tool
       |
       +------ BLOCK ------&amp;gt; Stop execution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Community Edition currently understands commands involving:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform
aws
kubectl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and contains default policies for destructive operations including:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;terraform destroy
kubectl delete
aws ec2 terminate-instances
aws rds delete-db-instance
aws s3 rm --recursive
aws cloudformation delete-stack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;safebox check &lt;span class="s2"&gt;"terraform plan"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;returns an allow decision.&lt;/p&gt;

&lt;p&gt;While:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;safebox check &lt;span class="s2"&gt;"terraform destroy"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is blocked by policy.&lt;/p&gt;

&lt;p&gt;SafeBox can also create executable proxies for supported tools.&lt;/p&gt;

&lt;p&gt;The idea is that an AI coding agent calling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;encounters the SafeBox proxy first.&lt;/p&gt;

&lt;p&gt;SafeBox evaluates the command and only invokes the real Terraform executable when the policy allows it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commands aren't always simple
&lt;/h2&gt;

&lt;p&gt;One interesting part of building the proof of concept was realizing that checking the first few words of a command isn't enough.&lt;/p&gt;

&lt;p&gt;An agent might generate:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;terraform destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;FOO&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;bar terraform destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/usr/local/bin/terraform destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"terraform destroy"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commands may also be chained:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;terraform plan &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; terraform destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So SafeBox normalizes commands before evaluating them.&lt;/p&gt;

&lt;p&gt;It also fails closed for shell constructs it doesn't understand sufficiently.&lt;/p&gt;

&lt;p&gt;The principle is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;SafeBox either understands the command sufficiently to evaluate it, or blocks it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That behavior is intentional.&lt;/p&gt;

&lt;p&gt;For an execution guardrail, I would rather have an unknown command require investigation than silently allow something the policy engine didn't understand.&lt;/p&gt;

&lt;h2&gt;
  
  
  The current implementation has an important limitation
&lt;/h2&gt;

&lt;p&gt;This is a proof of concept, not a hardened sandbox.&lt;/p&gt;

&lt;p&gt;That distinction matters.&lt;/p&gt;

&lt;p&gt;The current implementation relies on local executable proxies being placed earlier in &lt;code&gt;PATH&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A capable process can bypass that mechanism.&lt;/p&gt;

&lt;p&gt;For example, if it knows the absolute path of the real executable, a local proxy is not an OS-level security boundary.&lt;/p&gt;

&lt;p&gt;So the current architecture should not be interpreted as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AI agent
   |
IMPOSSIBLE-TO-BYPASS SECURITY BOUNDARY
   |
AWS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is better described as a local execution guardrail.&lt;/p&gt;

&lt;p&gt;That raises what I think is actually the more interesting architectural question.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where should the real enforcement boundary live?
&lt;/h2&gt;

&lt;p&gt;A production-grade implementation could potentially enforce policy at a stronger boundary.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;              +---------------------+
              |   AI coding agent   |
              +----------+----------+
                         |
                         v
              +---------------------+
              | Enforcement layer   |
              +----------+----------+
                         |
               Policy + context
                         |
              +----------+----------+
              |                     |
            ALLOW                  BLOCK
              |
              v
     +------------------+
     | Cloud credentials|
     | / execution path |
     +------------------+
              |
              v
             AWS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One possibility is credential brokering.&lt;/p&gt;

&lt;p&gt;Instead of giving an AI agent unrestricted AWS credentials and then trying to prevent dangerous commands locally, the enforcement system could control which credentials or permissions become available for a particular operation.&lt;/p&gt;

&lt;p&gt;Other approaches could include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;isolated execution environments;&lt;/li&gt;
&lt;li&gt;short-lived credentials;&lt;/li&gt;
&lt;li&gt;restricted IAM roles;&lt;/li&gt;
&lt;li&gt;explicit approval boundaries;&lt;/li&gt;
&lt;li&gt;Terraform plan inspection;&lt;/li&gt;
&lt;li&gt;AWS account awareness;&lt;/li&gt;
&lt;li&gt;production vs. non-production policies;&lt;/li&gt;
&lt;li&gt;organization-level policies;&lt;/li&gt;
&lt;li&gt;resource metadata;&lt;/li&gt;
&lt;li&gt;deletion-protection awareness;&lt;/li&gt;
&lt;li&gt;estimated blast radius.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, imagine an agent attempting to apply a Terraform plan.&lt;/p&gt;

&lt;p&gt;The policy engine knows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;AWS account: Production
Identity: AI-Agent-Role
Terraform plan:
  - Destroy RDS database
  - Delete S3 bucket
  - Modify 4 EC2 instances

RDS deletion protection: Enabled
Environment classification: Production
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A policy could then deterministically conclude:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BLOCK

Reason:
Production policy prohibits AI-initiated destruction
of persistent data resources.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's considerably more interesting to me than maintaining an ever-growing list of dangerous command strings.&lt;/p&gt;

&lt;h2&gt;
  
  
  But does this solve a real problem?
&lt;/h2&gt;

&lt;p&gt;That's the question I'm trying to answer before building anything more sophisticated.&lt;/p&gt;

&lt;p&gt;It's easy for engineers to see a technical problem and immediately start designing the larger system.&lt;/p&gt;

&lt;p&gt;Credential brokers.&lt;/p&gt;

&lt;p&gt;Policy engines.&lt;/p&gt;

&lt;p&gt;Terraform parsers.&lt;/p&gt;

&lt;p&gt;AWS integrations.&lt;/p&gt;

&lt;p&gt;Dashboards.&lt;/p&gt;

&lt;p&gt;Approval workflows.&lt;/p&gt;

&lt;p&gt;Before doing that, I'd rather find out whether teams actually want this additional enforcement boundary.&lt;/p&gt;

&lt;p&gt;Maybe the correct answer is simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;An AI agent should never receive permissions capable of performing those operations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Maybe existing IAM controls and isolated development environments already solve the problem adequately.&lt;/p&gt;

&lt;p&gt;Maybe companies will want agents capable of performing privileged infrastructure operations, but only behind deterministic policies.&lt;/p&gt;

&lt;p&gt;Or perhaps the useful boundary isn't command execution at all. It might be credentials, infrastructure plans, cloud APIs, or something else.&lt;/p&gt;

&lt;p&gt;Those are exactly the questions I'm interested in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The experiment is open source
&lt;/h2&gt;

&lt;p&gt;AWS SafeBox Community Edition is available on GitHub under the MIT License:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/aws-safebox/aws-safebox" rel="noopener noreferrer"&gt;github.com/aws-safebox/aws-safebox&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The current implementation is deliberately small.&lt;/p&gt;

&lt;p&gt;I'm not trying to present the proof of concept as a complete security platform.&lt;/p&gt;

&lt;p&gt;I'm using it to explore a broader question about how increasingly autonomous coding agents should interact with infrastructure.&lt;/p&gt;

&lt;p&gt;If you work with AI coding agents, AWS, Terraform, Kubernetes, DevOps, platform engineering, or cloud security, I'd be particularly interested in your perspective:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do AI coding agents need a deterministic enforcement boundary before they can modify infrastructure?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And if they do, &lt;strong&gt;where should that boundary actually live?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the command line?&lt;/p&gt;

&lt;p&gt;At the credential layer?&lt;/p&gt;

&lt;p&gt;At the Terraform plan?&lt;/p&gt;

&lt;p&gt;At the cloud API?&lt;/p&gt;

&lt;p&gt;Or somewhere else entirely?&lt;/p&gt;

&lt;p&gt;Even if you think the entire idea is unnecessary, I'd like to hear why.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>devops</category>
      <category>aws</category>
      <category>security</category>
    </item>
  </channel>
</rss>
