Secure AI Engineering

Building a Secure Agentic SDLC: AI That Writes, Tests and Deploys Code

In an agentic SDLC, AI agents take on work at every stage: specifying, coding, testing, reviewing, releasing and operating. This article describes how to secure that lifecycle end to end, combining agent governance, verification, provenance and deployment controls into one coherent model.

By EthicalHat Research · · 3 min read
Infographic: Controls across the agentic SDLC

Over the past eighteen months, AI agents have gradually taken on work at every stage of software delivery. Agents draft specifications from tickets, implement changes, write and run tests, review pull requests, triage failed builds, prepare releases and summarise incidents. In some organisations, agents author a significant share of the changes that reach production.

That is an agentic SDLC. Securing it is not about any single control; it is about designing the lifecycle so that speed from agents never removes the checks that keep software safe.

Principle 1: separation of powers

The most important structural control is borrowed from finance and operations: the one who does the work should not be the one who approves it.

  • Agents that write code do not approve it.
  • Agents that write tests for a change are not the only source of verification for that change.
  • Agents that prepare releases do not deploy to production.
  • Agents that operate (triage, summarise) have read access, not the ability to change production.
flowchart LR
  subgraph Write["Write"]
    AW[Coding agents]
    HW[Developers]
  end
  subgraph Verify["Verify (independent)"]
    CI[CI tests, scans,<br/>evals, policy]
    AR[Review agents<br/>first pass]
    HR[Human reviewers<br/>approve]
  end
  subgraph Ship["Ship"]
    PIPE[Deployment pipeline]
    HA[Human release<br/>approval for high risk]
  end
  Write --> Verify --> Ship

Principle 2: humans own intent and risk

Agents can draft specifications, but a human owns what "correct" means. Agents can propose risk acceptance for a finding, but a human accepts the risk. Agents can prepare a production change, but a human (or a deterministic pipeline with human-approved policy) authorises it.

Stage by stage

Specify

  • Humans own acceptance criteria; agents may draft and expand them.
  • Security requirements (authorisation rules, data handling, abuse cases) are part of the specification, so agents implement against them and tests verify them.

Build

  • Coding agents run in sandboxes without ambient credentials or production access.
  • They push to their own branches; protected branches are enforced server-side.
  • Their commits carry agent identity and task references, and are signed where possible.
  • Changes to sensitive paths (authentication, payments, infrastructure, CI configuration) require human code-owner approval.

Verify

  • Independent verification: tests from the specification, not only tests written by the implementing agent; property-based and mutation testing on critical code.
  • Security checks: SAST, SCA, secrets, IaC and container scanning on every change.
  • AI behaviour evals for any change touching AI features, including prompt-injection and data-leakage cases.
  • Review agents provide a first pass; human reviewers approve, with depth scaled to risk.

Release

  • Every artefact carries provenance: source commit, authoring identities (human and agent), build pipeline, checks run and results, approvals.
  • Policy at deployment verifies signatures and provenance: for example, no agent-authored change to a tier-1 service deploys without a human approval recorded in its provenance.
  • Progressive delivery (canaries, feature flags, automatic rollback) limits the impact of anything that slips through.

Operate

  • Operational agents have read-only access to telemetry and runbooks, and can open tickets or propose remediations.
  • Production changes, including incident remediation, go through humans or the pipeline, never directly from an agent's shell.

Governing the agents themselves

The agents are part of the lifecycle's attack surface:

  • Registry: every agent with owner, scope, tools and version.
  • Change control: prompts, instructions, tools and model versions are reviewed and tested before rollout.
  • Supply chain: agent tools, extensions and MCP servers are approved and pinned.
  • Runtime monitoring: detections for credential access, unusual egress and destructive commands from agent sessions.

Evidence

An agentic SDLC generates a lot of activity. Make it generate evidence too, automatically:

json
{
  "artifact": "registry.example.com/billing-api@sha256:7c2e...",
  "source": { "repo": "example/billing-api", "commit": "4f9a1c2" },
  "authors": [
    { "type": "agent", "id": "agent:code-maintainer", "version": "2026.06.2", "task": "BILL-2231" },
    { "type": "human", "id": "priya.n@example.com", "role": "editor" }
  ],
  "checks": { "tests": "pass", "mutation_score": 0.81, "sast": "pass", "sca": "pass", "ai_evals": "n/a" },
  "approvals": [ { "id": "sam.o@example.com", "role": "code_owner", "at": "2026-06-22T14:03:11Z" } ],
  "builder": "ci.example.com/pipelines/release@v5"
}

That record answers the questions auditors, customers and incident responders ask: what changed, who or what changed it, what checked it and who approved it.

The bottom line

A secure agentic SDLC keeps the speed agents bring and the checks software needs, by separating the powers to write, verify and ship, keeping humans in charge of intent and risk, governing the agents as part of the attack surface and carrying provenance with every change. It is DevSecOps, rebuilt for a lifecycle in which many of the participants are AI.

Our application security testing and secure SDLC teams help organisations design agentic delivery pipelines with these controls built in.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.