
Secure AI-generated code across the SDLC on AWS
AI agents write code faster than teams review it. At one company, pull requests with written human feedback fell from 39% to 21%. See where each check fits.
Series: A study on AI in the product lifecycle (4 articles)
- 2Secure AI-generated code across the SDLC on AWS This article
Part 1 of this series argued that AI speeds up whatever system it lands in, broken parts included. Security is one of the first places those broken parts show, because AI coding agents now write code faster than teams can review it. In a July 2026 Carnegie Mellon and Stanford study of 802 developers and nearly 200,000 pull requests at one company, the share of pull requests that got any written human feedback fell from 39% to 21%, as Semgrep's summary reports. Veracode's 2026 GenAI Code Security Report found that about 44% of AI code generation tasks in its tests produced code with a known vulnerability. When that code fails in production, operations teams absorb the cost. In an illustrative scenario, the DevOps Research and Assessment (DORA) report on the ROI of AI-assisted software development puts a change failure rate rising from 5% to 6% at $344,000 in added downtime for one organization.
My view is that deterministic checks should gate each phase, AI review should test whether code matches the spec, and a person should decide where judgment is needed, so review keeps pace with agents. In this article, I follow the software development lifecycle (SDLC) through five phases inside part 1's loop. For each phase, I map which checks to automate, where a person still decides, and which AWS agents can help.
How should you sort security controls for AI coding agents?
The AWS Security blog's control framework for AI coding agents sorts controls two ways. Author-time controls shape what the agent writes in the integrated development environment (IDE). Build-time controls gate that output in the pipeline. Deterministic checks, such as secrets detection, static application security testing (SAST), software composition analysis (SCA), and infrastructure as code (IaC) scanning, return the same answer for the same code and rule version. AI review asks whether the code does what the spec intended, because agent code can pass every scanner and still be wrong. Figure 1 shows deterministic checks, AI review, and human decisions in each phase, inside part 1's build, ship, and measure stages.

Figure 1: Deterministic, AI, and human checks in each SDLC phase.
Design: security starts in the spec
In my experience, the most efficient place to fix a design flaw is before any code exists. AWS Continuum threat modeling, introduced in the AWS Continuum launch post , generates a threat model from design documents or source code. Attach that threat model to design specifications. The AI-Driven Development Lifecycle , which AWS open-sourced, has a DevSecOps agent that contributes a threat model to the nonfunctional requirements stage, and approval gates that stop the work until a person signs off.
Code: rules for the agent, limits on its reach
Your security team can write its rules once, in plain language, in a steering file for Kiro, the agentic IDE from AWS. The file loads in every session. Typical rules call for least-privilege AWS Identity and Access Management (IAM) policies with no wildcard resource names, credentials from AWS Secrets Manager , and public access blocked on every Amazon Simple Storage Service (Amazon S3) bucket. Workspace steering in
.kiro/steering/ takes priority over global steering in ~/.kiro/steering/ , and Kiro also reads AGENTS.md files anywhere in the workspace. Because steering guides the agent but doesn't enforce rules, Kiro hooks back it up by running scanners on file save and asking the agent to check its work against the spec when a task completes. If you install the AI-Driven Development Lifecycle , it adds its own AGENTS.md , steering for your coding agent, and files of learned rules. Put .kiro/steering/ , .kiro/hooks/ , every AGENTS.md , and those rule files under code owner review, so no one can weaken a rule without review. Global steering lives outside the repository, so distribute it from a reviewed central repository.Steering won't stop an agent that outside text can redirect. Prompt injection, where untrusted content steers an agent into leaking secrets or calling tools, is LLM01, the top risk in the 2025 Open Worldwide Application Security Project (OWASP) Top 10 for Large Language Model (LLM) Applications . An LLM can't reliably separate instructions from data in one context window, so consider splitting the work between an agent that reads untrusted content and one that acts. Pass only structured, validated output between them, so injected instructions don't travel with the data.

Figure 2: Separate the agent that reads untrusted content from the agent that acts.
Allow only Model Context Protocol (MCP) servers your team has reviewed, and give each one its own scoped credential instead of a developer's credentials. Agents can also suggest package names that don't exist, and an attacker can register them. Resolve dependencies from a private registry such as AWS CodeArtifact , with package origin controls that limit what it pulls from public upstreams. Require a person to approve irreversible agent actions, avoid blanket auto-approval, keep secrets out of the agent's context, and run agents in sandboxes that can't push to protected branches. Log each tool call and approval so you can audit what the agent did and who signed off.
How do you review pull requests that agents write?
When agents write most of the code, automated checks throughout the pipeline cut what a person has to read. Run secrets detection first because it's the cheapest check for a high-severity class of issue. Run it as a pre-commit hook too, because a secret caught at pull request time has already been pushed. Rotate any exposed secret, because deleting the commit doesn't revoke it. SAST, SCA, and IaC scanning follow, each with a severity threshold that blocks merges to the main branch and only warns on feature branches. AWS CodeBuild runs each scanner as a build action, and AWS CodePipeline passes results to the approval steps. An LLM reviewer then pre-screens each pull request for spec compliance and scope creep, ideally a different model from the one that wrote the code. Give that reviewer read-only access, and let it comment but not approve. Figure 3 shows the order of these gates from pull request review through operate.

Figure 3: Pipeline gates from pull request (PR) review through operate.
The release management capability in AWS DevOps Agent assesses each code change for release readiness. It checks dependency impact across repositories and reviews access control changes against AWS Well-Architected Framework best practices.
With those results in hand, a person approves the change for correctness and business logic.
Build and test: the last check before production
Scanners read code, while penetration testing attacks the running application. Continuum pen testing, which took over the penetration testing capability of AWS Security Agent, runs on-demand tests against deployed applications and source code. It uses the design documents and IaC you provide as context. Point it only at a test or staging environment you're authorized to test.
Operate: roll out slowly, then investigate fast
A bad change that reaches every user at once can become an outage, so start with a gradual rollout. AWS AppConfig ships feature flags and configuration in steps, and AWS CodeDeploy ships code. Both can roll back automatically if an Amazon CloudWatch alarm fires during the deployment.
AWS DevOps Agent's incident investigation, generally available since March 31, 2026 , starts when an alert fires and works toward a root cause and mitigation steps. In the launch announcement , AWS reports that Western Governors University's site reliability engineering team cut total resolution time for one production investigation from an estimated two hours to 28 minutes.
Security findings accumulate too, and you can't work a backlog that grows at agent speed in arrival order. AWS Continuum for code vulnerabilities confirms which findings are exploitable in your environment and ranks the resulting issues by business impact. It builds a context graph from your code and, if you set up a collector, your AWS environment, then runs a sandboxed exploit for findings it can reproduce. For each confirmed issue, it opens a pull request with a code patch, a dependency upgrade, or a configuration change. A person reviews and merges every fix.
Back to design: every finding becomes a rule
The loop closes when a lesson from operate changes what the agent writes next. AWS DevOps Agent analyzes past incidents and recommends changes to observability, infrastructure, the deployment pipeline, and application resilience. When a scanner or reviewer catches the same security issue twice, add a steering rule so the agent stops producing it and a regression test that catches it if it returns. The AI-Driven Development Lifecycle builds part of this in. It keeps learned rules alongside team knowledge, and it records every approval-gate decision in an audit trail kept in the project repository. The open source Project CodeGuard publishes starter steering rules for common risk classes.
When can an agent own a security check?
In part 1's last trust level, autonomous, an agent owns a gate once its measured error rate falls below the human error rate on that task. For security gates, add five conditions. Weight misses by severity, test the agent against prompt injection aimed at the gate, re-measure after every model change, keep deterministic scanners in place, and keep a named person accountable for each gate. The control framework says lower-risk changes might qualify for automated approval as tooling matures. To know when one does, start tracking false positives, escaped issues, time to fix, and change failure rate for your human process now.
Where to start
You can make two changes this month. Add a security section and a threat model to your spec template, and run secrets detection and SAST as pass/fail gates in your pipeline.
Further reading
- Part 1: Measure AI development speed across the product lifecycle (AWS Builder Center)
- Balancing speed and safety: A control framework for AI coding agents (AWS Security blog)
- Open-Sourcing Adaptive Workflows for AI-Driven Development Life Cycle (AWS DevOps blog)
- AWS DevOps Agent adds release management capabilities (AWS News blog)
About the Author
Michael Purpura is a Senior Global Private Equity Solutions Architect at AWS. He works with private equity firms and their portfolio companies to structure AI adoption around measurable business outcomes.
Series: A study on AI in the product lifecycle (4 articles)
- 2Secure AI-generated code across the SDLC on AWS This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article