TL;DR: AI-assisted code generation is accelerating software output faster than security review can keep up, while static analysis that explains risk in developer context may finally narrow the gap, according to Semgrep. The deeper shift is upstream: organisations are moving from catching bad code in production to preventing it in the IDE and pull request.
At a glance
What this is: This is an independent Semgrep essay arguing that security still fails upstream, even as AI changes how code is written and reviewed.
Why it matters: It matters because IAM, NHI, and broader security programmes increasingly depend on code-centric controls, developer workflow integration, and earlier prevention rather than post-shipment detection.
👉 Read Semgrep's analysis of AI-assisted code security and upstream prevention
Context
Security teams still struggle most when the control point is too far from where risk is introduced. In code-heavy environments, that means weaknesses are created during development, then discovered later by scanners, incidents, or customers. AI-assisted coding increases that pressure by raising the volume of change, which makes prevention at the point of creation more valuable than ever.
The identity angle is real even in a code-security essay because modern software depends on secrets, service credentials, and machine-to-machine access paths that are embedded in code and pipelines. When developers move faster, non-human identities and secrets governance become part of the same control problem, not a separate discipline.
Key questions
Q: How should security teams control AI-assisted coding without slowing developers down?
A: Put policy into the IDE so security guidance appears during code creation, not after commit. Teams should use safe defaults, prompt shaping, and low-friction remediation paths. The goal is to reduce insecure output while preserving developer flow, because delayed controls create rework and encourage bypasses.
Q: Why do leaked secrets create an identity governance problem, not just a code problem?
A: Because a leaked secret is a live credential with an owner, scope and lifecycle. If it remains valid after exposure, it can be abused like any other non-human identity. Governance has to cover discovery, revocation, rotation and auditability, otherwise the organisation only knows that the secret existed, not that it was removed.
Q: What do security teams get wrong about review loops in AI-assisted development?
A: Teams often assume a review loop automatically means control is preserved. In practice, the agent may still make substantial changes before the developer sees them, especially when planning is hidden or optional. The control issue is not whether review exists, but whether review happens early enough to constrain the change path.
Q: What should organisations do when code security and NHI governance overlap?
A: They should manage them as a shared control plane. Secrets, service accounts, and pipeline credentials should be inventoried alongside application assets, with rotation and revocation tied to ownership. That prevents code changes from creating undocumented access paths and helps IAM teams see where machine identity risk begins.
Technical breakdown
Why code creation is now the main risk surface
The core technical point is that application risk is increasingly introduced before code reaches runtime. AI-assisted generation speeds up feature delivery, but it also scales familiar mistakes such as unsafe input handling, weak authentication logic, and embedded secrets. Static analysis remains useful, but its value rises when it is paired with context, developer workflow integration, and fast feedback loops. The shift is not from secure coding to scanning. It is from late discovery to earlier prevention in the software lifecycle.
Practical implication: move detection into the IDE and pull request so vulnerable patterns are blocked before merge.
How AI changes the economics of prevention
AI does two things at once. It increases the amount of code that needs review, and it creates a better opportunity to explain findings in natural language that developers can act on. That matters because many security findings fail not on detection, but on comprehension and prioritisation. Tools that surface why a pattern is dangerous at the moment of authoring can reduce friction between security and development. The technical challenge is to keep precision high enough that teams do not tune the control out.
Practical implication: tune developer-facing security signals for explanation quality, not just alert volume.
Secrets in code remain an identity problem
Secrets exposure is a code issue, but its security consequence is identity abuse. API keys, tokens, certificates, and service account credentials turn source code and pipelines into access brokers. Once a secret leaks, attackers move from code review failure to credential misuse and cloud or application access. That is why secrets scanning, rotation, and lifecycle governance are part of identity control, not just application hygiene. The boundary between application security and machine identity governance is thinner than many programmes assume.
Practical implication: treat secret detection as an identity control and tie it to rotation and revocation workflows.
Threat narrative
Attacker objective: The attacker aims to turn code-level mistakes into usable access, then leverage that access for data theft, lateral movement, or persistence.
- Entry occurs when sensitive secrets or unsafe code patterns are introduced into repositories, build pipelines, or generated code.
- Escalation follows when attackers or downstream users exploit exposed credentials, weak authorisation logic, or unsafe dependencies.
- Impact is reached when those credentials or flaws enable unauthorised access, data exposure, or broader compromise of application and cloud environments.
NHI Mgmt Group analysis
AI-assisted development has turned code review into an upstream security control, not a downstream quality check. The article is right to frame prevention as the leverage point because the volume and speed of code creation now outpace traditional review habits. Security teams that still rely on post-commit scanning are working at the wrong stage of the lifecycle. The practical conclusion is that developer workflows must become enforcement points, not just observation points.
Secrets are the identity layer hidden inside application code. When credentials are embedded in repositories or generated into pipelines, the issue is no longer only secure coding. It becomes NHI governance because the secret itself is a machine identity, and leaked machine identities often create the shortest path to compromise. Programmes that separate application security from secrets management are missing the actual control plane. The practical conclusion is that code security and NHI governance need a shared operating model.
Developer context is now a control variable. Security findings that cannot explain impact in the language of code review, pull requests, and runtime consequences will keep losing to delivery pressure. That is why context-rich static analysis matters more than another generic alert stream. The practical conclusion is that detection quality should be measured by whether developers can act without translation.
AI does not remove the need for governance, it moves the governance boundary closer to creation. AI-generated code increases output, but it also increases the number of opportunities to prevent repeatable mistakes before they ship. That makes policy-as-code, secure defaults, and identity-aware pipeline controls more important. The practical conclusion is that governance must be embedded where code is authored, not bolted on after release.
Code-security maturity is increasingly a proxy for identity resilience. The more software depends on secrets, service accounts, and automated build paths, the more application security failures become identity failures. That convergence matters for IAM and PAM teams because the blast radius of a leaked secret often extends beyond the application team that introduced it. The practical conclusion is that code-security strategy should be reviewed alongside machine identity inventory and secret lifecycle controls.
What this signals
Secrets drift is becoming a governance signal, not just an AppSec metric. When credentials live in code, the speed of detection and the speed of revocation matter more than the number of alerts generated. Programmes should expect auditors and internal risk teams to care more about how quickly leaked secrets are retired than how many were found.
The practical shift is toward control points that sit inside delivery workflows, where policy can act before code is merged. For teams with IAM and PAM responsibilities, that means closer integration between repository scanning, rotation automation, and access ownership, rather than treating secrets management as a separate hygiene task.
For practitioners
- Shift security enforcement into the IDE and pull request Block high-confidence unsafe patterns before merge, and route lower-confidence findings into developer-native review with clear remediation guidance.
- Treat secret scanning as identity governance Connect secret detection to revocation, rotation, and ownership workflows so exposed API keys and tokens are not just flagged but actually retired.
- Measure developer-facing context quality Track how often findings are resolved without escalation or rework, because explanation quality is what determines whether teams can act quickly.
- Align AppSec with machine identity inventory Map secrets, service accounts, and pipeline credentials to their owning systems so code changes cannot introduce undocumented access paths.
- Use AI to reduce translation friction, not accountability Adopt security tooling that explains why a flaw matters in the authoring context, while keeping human ownership for policy decisions and approvals.
Key takeaways
- AI-assisted coding is making upstream prevention more valuable than downstream cleanup.
- Leaked secrets are an identity problem as much as a code quality problem because they become usable machine credentials.
- Security teams need controls that live in developer workflows, connect to rotation, and explain risk in context.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and MITRE ATT&CK address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-03 | Secrets exposure and rotation gaps are central to the article's identity control implications. |
| NIST CSF 2.0 | PR.AC-4 | Least-privilege and access governance apply to machine credentials in code and pipelines. |
| NIST SP 800-53 Rev 5 | IA-5 | Authenticator management governs the lifecycle of API keys, tokens, and certificates. |
| CIS Controls v8 | CIS-5 , Account Management | Machine account and secret governance map directly to account lifecycle control. |
| MITRE ATT&CK | TA0006 , Credential Access; TA0008 , Lateral Movement | The attack pattern described begins with credential exposure and can progress to broader compromise. |
Map leaked secrets to credential-access and lateral-movement techniques to prioritise containment.
Key terms
- Machine Identity: The digital identity of a machine, device, or workload — such as a server, container, or VM — used to authenticate it within a network. Sometimes used interchangeably with NHI, though NHI is the broader category.
- Secrets Management: The discipline of securely storing, distributing, rotating, and auditing secrets across an organisation's systems and pipelines — typically implemented via a centralised secrets vault such as HashiCorp Vault, AWS Secrets Manager, or Akeyless.
- Developer-native Security Feedback: Developer-native security feedback is risk information delivered inside the tools engineers already use, such as editors and pull requests. It is designed to explain impact in context, so developers can fix issues without translating security findings into code-level actions.
- Upstream Prevention: Upstream prevention is the practice of stopping security defects before code is merged or released. It shifts control earlier in the lifecycle, where remediation is cheaper and blast radius is smaller. For application security, this means prioritising authoring-time and review-time enforcement over late-stage detection alone.
What's in the full article
Semgrep's full article covers the operational detail this post intentionally leaves for the source:
- How the vendor expects static analysis to fit into the developer workflow without overwhelming pull request review.
- Examples of the specific feedback loop between code review, developer education, and security triage.
- The article's broader view on how AI changes the balance between prevention and detection in software delivery.
- The author's perspective on how security and development can function as one team rather than separate disciplines.
Deepen your knowledge
NHI Mgmt Group’s NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, and secrets management. It is designed for practitioners aligning identity controls with broader security and engineering programmes.
Published by the NHIMG editorial team on August 2, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org