Subscribe to the Non-Human & AI Identity Journal

What breaks when security only happens after code is written?

Late-stage security turns every finding into a backlog problem and allows high-risk issues to travel into build, supply chain, and runtime environments. By then, remediation is slower, context is poorer, and the chance of exploitation is much higher. That is why stage-gated security underperforms when AI accelerates development.

Why This Matters for Security Teams

Security that starts after code is written treats risk as a review event instead of a design constraint. That approach is especially weak in fast-moving delivery pipelines, where defects can be copied into templates, infrastructure as code, dependencies, and AI-generated code before anyone notices. The NIST Cybersecurity Framework 2.0 makes the point implicitly: security outcomes depend on embedding governance, risk management, and protective controls throughout the lifecycle, not only at release time.

The practical problem is that late findings are expensive to triage and often ambiguous to fix. Engineers may no longer know why a pattern exists, who approved it, or whether it was introduced manually, by a reusable component, or by an AI assistant. That ambiguity matters because remediation decisions are slower when ownership is unclear and evidence is incomplete. It also means the same issue can recur in multiple services if the underlying pattern is not removed from source templates and guardrails.

For security leaders, the deeper concern is that stage-gated review creates false confidence. A clean final scan does not mean the design was secure, only that visible issues were caught before launch. In practice, many security teams encounter critical misconfigurations only after deployment telemetry, customer reports, or incident response has already revealed the gap.

How It Works in Practice

Shift-left security is not a slogan; it is a workflow change. The goal is to move the cheapest and most reliable checks as close as possible to the point where code, configuration, and prompts are created. That means secure defaults in templates, policy checks in pull requests, dependency validation in build pipelines, and runtime monitoring for what static review cannot know in advance. For AI-assisted development, this also includes prompt review, output validation, and provenance checks for generated code and model outputs, because the risk surface is broader than source files alone.

A practical implementation usually combines preventive and detective controls:

  • Repository policies that block unsafe patterns before merge.
  • Automated secret scanning and dependency review in CI.
  • Infrastructure as code checks for cloud and access misconfigurations.
  • Threat modeling for high-risk changes before implementation begins.
  • Runtime detection for abuse, drift, and unexpected privilege use.

This aligns with modern guidance from the OWASP Top 10 for Large Language Model Applications, which highlights prompt injection, insecure output handling, and excessive agency as development-time concerns, not just production issues. It also fits broader lifecycle thinking in the NIST AI Risk Management Framework, where governance and measurement are expected before deployment.

In mature environments, security teams define quality gates for risk rather than for documents. A merge should fail if a change introduces a public secret, weak authorization logic, unapproved library, or unsafe AI tool invocation. The best programs also keep feedback loops short so developers get actionable feedback while the change is still fresh. These controls tend to break down in monorepos with heavy code generation because shared components and rapid auto-generated changes can overwhelm review capacity and blur ownership.

Common Variations and Edge Cases

Tighter pre-merge control often increases developer friction and pipeline overhead, requiring organisations to balance speed against assurance. That tradeoff is real, especially in release trains, regulated environments, and teams that depend on generated code or reusable platform modules. Best practice is evolving, and there is no universal standard for exactly where every check should sit.

One common edge case is low-risk cosmetic change. Not every edit deserves the same level of scrutiny, but teams need a consistent way to classify exceptions. Another is AI-generated code, where the security issue may be less about the final diff and more about the prompt, the source corpus, or the tool permissions behind the output. In those cases, security should examine the full chain of creation, not just the artifact.

For organisations using DevSecOps or platform engineering, the strongest pattern is to make secure paths easier than insecure ones. That may mean opinionated templates, approved modules, and guardrails that reject dangerous defaults automatically. Where this breaks down is in shadow tooling, emergency hotfixes, and highly distributed teams that bypass standard pipelines because speed has not been engineered into the approved path.

For deeper lifecycle governance, practitioners can also anchor decisions to the NIST Cybersecurity Framework 2.0 and treat pre-release assurance as one control layer within a broader risk program, not as the whole program.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 and MITRE ATLAS address the attack surface, NIST CSF 2.0 and NIST AI RMF set the technical controls, and EU AI Act define the regulatory obligations.

Framework Control / Reference Relevance
NIST CSF 2.0 GV.OC-01 Security must be built into lifecycle governance, not only checked at release.
NIST AI RMF GOVERN AI-assisted code creation needs governance before deployment and release.
OWASP Agentic AI Top 10 A2 Agentic and AI-assisted development can expand unsafe tool use and output risk.
MITRE ATLAS AML.TA0001 Model manipulation and poisoned outputs can enter pipelines if checked too late.
EU AI Act High-risk AI governance requires controls across the system lifecycle.

Define ownership and risk expectations early so development controls are part of governance.