
We Audited One Workflow. We Pushed Another: Hard Lessons from Kiro and AWS IaC
An AI-assisted AWS IaC workflow passed our audit—but an older version reached GitHub. Across 53 test cases and 15 security scenarios, I explored bounded remediation, GitHub App checks, artifact integrity, and the limits of agentic development. Here's what failed, what worked, and what I'd change.
We Audited One Workflow. We Pushed Another: Hard Lessons from Kiro and AWS IaC
The workflow I reviewed was safe.
It didn't reference a private key. It didn't mint a token. It didn't call the GitHub API.
But when I opened the pull request, GitHub received an older workflow that still contained all three.
The AI-generated artifact I had audited was not the artifact I actually pushed.
Fortunately, GitHub Environment protection rejected the job before any steps executed. I found no evidence that the private key was accessed.
The incident exposed a gap I had overlooked: reviewing generated code does not prove that the same code will be published or executed.
This happened while I was building an AWS Infrastructure as Code (IaC) remediation workflow using Kiro, GitHub Actions, and a GitHub App.
In this article, I'll share what I learned from 53 comparison cases, 15 security scenarios, an actual artifact mismatch, and the guardrails I built afterward.
The results were not all successful. That's an important part of the story.
The original problem: An AI can fix an error and still make the wrong change
Imagine asking a coding agent to fix an AWS CloudFormation template.
The template contains this DynamoDB configuration:
BillingMode: PAY_PER_REQUESTProvisionedThroughput: ReadCapacityUnits: 5 WriteCapacityUnits: 5For
PAY_PER_REQUEST , the provisioned throughput configuration is inappropriate.The intended fix is straightforward: remove
ProvisionedThroughput while preserving the billing mode.But what if the agent also changes an IAM permission from:
Action: dynamodb:PutItemto:
Action: dynamodb:*The original configuration problem might disappear, but the remediation has introduced a broader security risk.
A successful lint check isn't enough to establish that the entire change is acceptable.
I wanted to answer a more precise question:
Can we allow an AI agent to fix a specific IaC problem while independently enforcing what it must not change?
That became the foundation of AWS IaC Bounded Remediation.
From review findings to bounded remediation
In v1.1.0, I introduced a read-only Delta Tool that compares CloudFormation templates and review findings between Base and Head revisions.
It separates structural differences from finding changes.
Finding Delta uses categories such as
New , Resolved , Unchanged , Unconfirmed , and Ambiguous .That distinction taught me something important.
A resolved finding does not necessarily mean a safe remediation.
For example, deleting a resource can make its findings disappear. That doesn't mean deleting the resource was the right fix.
Similarly, when the comparison lacks sufficient evidence, the result should not silently become a success.
In v1.1, unsupported assumptions are explicitly recorded as declared rather than verified.
The next step was to introduce a Remediation Contract: a human-approved definition of what the agent is allowed to change and what must remain unchanged.
Conceptually, the DynamoDB example becomes:
Contract element | Requirement |
|---|---|
Objective | Remove the incompatible throughput configuration |
Allowed change | Delete the target table's ProvisionedThroughput |
Invariants | Preserve unrelated properties and IAM permissions |
Validation | Verify the objective and detect out-of-scope modifications |
This is a conceptual example, not the project's literal contract schema.
The validator must distinguish four outcomes:
-
VERIFIED: the required contract conditions were satisfied.
-
BLOCKED: a prohibited change or contract violation was detected.
-
UNVERIFIED: sufficient evidence was unavailable.
-
ERROR: the verification process itself failed.
The key is to avoid treating missing evidence as evidence of safety.
The architecture: Separate generation, verification, and authorization
I used Kiro to help develop the implementation and investigate failures.
But I didn't want the coding agent to be the final authority over its own output.
The experimental architecture separated the responsibilities:
Human-approved Remediation Contract | v Kiro / Coding Agent Proposed IaC change | v Independent Validator Objective + Invariant Checks | v Commit-bound Evidence | v GitHub App Check Publisher | v Required Check / PR Gate | v Human ReviewThe distinction matters.
Generating a change is not the same as validating it. Validating a change is not the same as authorizing its integration.
In the GitHub experiment, the workflow that verified changes was separated from the job that published the authoritative check using GitHub App credentials.
The publishing job used a protected GitHub Environment.
The goal was to prevent an untrusted pull request from simply declaring its own remediation successful.
This experiment did not automatically deploy AWS resources or merge pull requests. Its scope was candidate validation and GitHub-side acceptance control.
What did the experiments show?
I used two different test sets. Their denominators should not be mixed.
53 comparison cases
In the local comparison, I evaluated 53 cases across implementations including a bounded remediation verifier and a hand-written script using equivalent rules and evidence conditions.
For the bounded verifier, unsafe changes were accepted in:
0 out of 28 unsafe-change cases.
That's encouraging, but there's an important limitation.
The hand-written script produced the same decisions across all 53 cases.
So I cannot claim that the bounded verifier detects more unsafe changes than an equivalent deterministic implementation.
The potential value is in standardizing the contract, evidence, traceability, and integration—not in claiming that an AI-native implementation automatically makes better security decisions.
Those benefits still need to be measured through real developer workflows.
15 GitHub security scenarios
The subsequent GitHub acceptance evaluation covered 15 scenarios.
Outcome | Count |
|---|---|
PASS | 8 |
PARTIAL | 1 |
FAILED | 3 |
NOT_PROVEN | 3 |
The overall Phase 1 verdict was PARTIAL, not PASS.
In addition, 11 GitHub gate decisions matched the corresponding offline simulation outcomes, including the expected rejection behavior.
Three scenarios—G3, G3S, and G6—failed their predefined acceptance criteria because spoofed checks or statuses returned
isRequired=true .The legitimate App's failed check still blocked merging in those scenarios.
That distinction matters: a blocked pull request does not independently prove that source pinning rejected the spoofed result.
I kept the issuer-pinning conclusion as
NOT_PROVEN .A surprising finding: A successful App check can still be blocked
One of the most interesting observations came from testing GitHub checks and commit statuses with the same name.
I configured the required check as:
remediation-gate/verified Then I posted additional commit statuses under the same context name using owner credentials.
The results were:
Legitimate App check | Same-name commit status | Observed result |
|---|---|---|
success | success | CLEAN |
success | failure | BLOCKED |
failure | success | BLOCKED |
The second case was particularly interesting.
A legitimate, successful remediation could be blocked by a failure status published under the same name.
This was an availability problem rather than an observed unauthorized merge.
GitHub's documentation explains that when a required name exists as both a check and a commit status, both need to pass.
This was not evidence of a GitHub vulnerability or an attack by an unauthenticated outsider. The experiment used an account authorized to post statuses.
Still, it revealed an important design requirement:
Preventing unauthorized changes and preventing legitimate changes from being blocked are different security and reliability objectives.
A trustworthy agentic workflow needs to consider both.
The failure that changed the design: Artifact drift
Now back to the incident from the beginning.
I was testing whether a workflow from a non-main branch could access a protected GitHub Environment called
remediation-publisher .Originally, the experimental workflow contained steps that referenced the GitHub App private key, minted an App token, and attempted to publish a check.
Before execution, I changed the intended probe to a harmless version that only requested the Environment and printed a fixed string.
Kiro reviewed the new source definition.
However, the helper had already created the local Git branch.
Changing the source definition did not regenerate that branch's commit.
The push function then sent the existing commit to GitHub.
Audited source definition | vHarmless probe approved | | Existing branch was not rebuilt vOld committed workflow | vGitHub received the stale artifactGitHub did not substitute or modify the workflow. It executed the commit that my process had pushed.
This was an artifact integrity failure in my tooling.
Why the private key wasn't accessed in the observed runs
The old workflow was present in a pull request, but both its
push and pull_request runs failed before any job steps executed.GitHub returned explicit annotations saying that the non-main references were not allowed to deploy to
remediation-publisher because of Environment protection rules.Both jobs reported zero executed steps.
That was evidence that the configured Environment boundary worked for those specific runs.
It was not proof that every possible route to the private key was safe.
GitHub documents that Environment protection rules must pass before a job is sent to a runner, and Environment secrets become available only afterward.
Even though this protection prevented the dangerous steps from running, the original process had still published an artifact that differed from the approved source.
I preserved that incident rather than reclassifying it as a successful test.
The correction: Verify the commit, not just the generated file
To prevent a recurrence, I added an Artifact Integrity Gate.
The corrected process checks the complete commit tree against the approved source before pushing.
It verifies file paths, contents, and file modes, rejecting unexpected files and mismatches.
More importantly, the push uses the verified commit SHA itself:
git push <repository-url> \ <verified-commit-sha>:refs/heads/<branch>The helper rechecks the exact commit before pushing and verifies the remote SHA afterward.
If the source can't be verified, the branch has moved unexpectedly, or the committed content differs, the operation stops.
I tested the corrected path in a new G11b scenario rather than rewriting the original G11 evidence.
The harmless probe was:
name: publisher-probeon: [pull_request, push]permissions: {}
jobs: probe: runs-on: ubuntu-24.04 environment: remediation-publisher steps: - name: Request publisher environment run: 'echo "publisher-probe requested; no secret read; no token minted"'This version contains no secret reference, token generation, or API call.
- The published workflow matched the audited source by SHA-256.
- The remote pull-request head matched the verified commit.
- The SHA-pinned push succeeded.
- Both the
pushandpull_requestprobe jobs were rejected by Environment protection rules.
- Neither job executed any steps.
The relevant workflow runs are available here:
This provided evidence for two separate properties:
Artifact integrity: the source I audited was the source published to GitHub.
Environment enforcement: the published workflow could not execute its job from the tested non-main references.
Neither claim alone would have been sufficient.
One more uncomfortable lesson: The evidence pipeline needs testing too
While evaluating the security boundaries, I also discovered weaknesses in the evaluation infrastructure.
For example, some failures were initially classified using process exit codes without distinguishing an expected policy rejection from a tool failure.
In another case, the evaluator did not enforce the acceptance rule concerning
isRequired , even though that rule had been established before the GitHub experiment.A time-parsing problem also produced an invalid, negative protection-window measurement.
These weren't just reporting issues.
They affected how experimental outcomes could be interpreted.
I corrected the final evaluation, retained failed scenarios as FAILED, and preserved superseded evidence rather than silently replacing history.
One protection-window experiment on an earlier demo exceeded its 120-minute limit, taking 125 minutes. The later demo recorded a bounded duration of approximately 52.8–65.2 seconds.
The failed earlier result remained part of the record.
A large test suite is useful, but it cannot establish experimental credibility if the acceptance criteria and evaluator disagree.
Evidence generation is itself software that needs version control, regression tests, and traceability.
Five engineering practices I'd carry into another agentic project
These are the practices I would prioritize before allowing an agentic development workflow to publish changes:
1. Define the permitted change, not just the desired fix.
Specify the objective, allowed modifications, preserved invariants, and required validation evidence.
2. Keep generation and acceptance independent.
Do not let the component that proposes a change unilaterally establish that it is safe.
3. Bind evidence to an exact artifact.
The reviewed source, committed tree, validation report, and published commit must be connected by verifiable identities.
4. Treat security and availability separately.
A gate that prevents unauthorized changes may still allow legitimate changes to be blocked by conflicting statuses or operational failures.
5. Make evaluation reproducible.
Predefine acceptance criteria, preserve raw observations, and distinguish
FAILED from NOT_PROVEN . Do not rewrite historical results to make a project appear successful.What's next?
The publicly released v1.1.0 plugin provides read-only review-delta capabilities.
The bounded remediation verifier, GitHub App gate, and experimental helper are a later development effort. They are not all part of the v1.1.0 release.
There are important limitations still to address.
Issuer-pinning behavior remains incompletely proven. Some actor and administrative boundaries were not tested. The experimental helper and evidence pipeline also need to become easier for other developers to reproduce.
Most importantly, I haven't yet demonstrated that Kiro-driven remediation reduces developer effort compared with a well-designed deterministic workflow.
That is a question for the next phase.
The goal is to move from an interesting security experiment toward a reusable OSS workflow that AWS developers can set up, inspect, and validate independently.
Final thought
The biggest lesson wasn't that an AI agent made a bad change.
It was that I had inspected one artifact and authorized a process that published another.
The same class of mistake can happen without AI. Agentic development makes it especially important to establish where authority, evidence, and responsibility sit.
For AWS IaC remediation, the question should not stop at:
Did the agent fix the problem?
It should also ask:
Did it stay within the approved boundaries? Can I verify the evidence? And is the artifact being published exactly the one I approved?
That's the engineering model I'm continuing to build.
I'd be interested to hear how other builders bind AI-reviewed changes to the exact commits their automation ultimately publishes.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article