TL;DR: Across more than 150 large language models, only 55% of AI-generated code passes basic security tests while syntax correctness exceeds 95%, according to Veracode, leaving security teams with fast-moving code that often looks right but still ships known flaws. The core problem is that speed now outpaces trust, and manual review cannot keep up with machine-scale code generation.
At a glance
What this is: AI coding tools are producing code that often passes syntax and functional tests while failing security tests, creating a trust gap between development speed and secure delivery.
Why it matters: For IAM and security teams, this matters because insecure code expands the attack surface, complicates governance over application pipelines, and increases downstream risk to identities, secrets, and privileged workflows.
By the numbers:
- Across more than 150 large language models tested, only 55% of AI-generated code passes basic security tests.
- 95%.
- Only 42.2% of organisations have fully implemented secure coding and code review practices.
- Security debt now affects 82% of organisations, up from 74% a year ago.
👉 Read Veracode's analysis of AI-generated code security gaps and remediation priorities
Context
AI coding tools increase delivery speed, but they also make software trust harder to prove. In practice, that means code can look correct, compile cleanly, and still contain known vulnerabilities that slip past normal development workflows. For identity and security programmes, the issue reaches beyond application security because vulnerable code frequently handles authentication, authorisation, secrets, and access-dependent logic.
The governance gap is not that teams lack scanners. It is that many organisations still rely on manual review, inconsistent secure prompting, and after-the-fact remediation in environments where AI-generated output arrives at machine speed. That creates a control mismatch for IAM, PAM, and secret handling in application pipelines, where the starting position in many enterprises is already behind the pace of development.
AI-generated code trust gap: the core problem is not code volume alone, but the widening distance between functional correctness and security correctness. That gap is now a software governance issue, not just a developer productivity issue.
Key questions
Q: How should security teams govern AI-generated code in production pipelines?
A: Security teams should treat AI-generated code as a controlled identity event, not just a development artifact. Require human approval, traceable authorship, scoped workload identities, and evidence of intent before production promotion. The goal is to preserve provenance and limit blast radius when generated logic behaves unexpectedly.
Q: Why do AI coding tools create a security risk even when code looks correct?
A: They optimise for syntax and pattern completion, not contextual security reasoning. Code can compile, satisfy tests, and still mishandle input, logging, or trust boundaries in ways that create exploitable flaws. That is why functional correctness and security correctness must be measured separately in governed pipelines.
Q: What do security teams get wrong about AI-generated code risk?
A: They often focus on catching insecure output after code is written, which is too late for AI-native workflows. The more important control point is the moment the agent is allowed to initiate the action. If that step is not governed, testing becomes a detection layer rather than a prevention layer.
Q: Should organisations prioritise secure coding controls before expanding AI developer tools?
A: Yes, if the current delivery process cannot verify code security at the same pace it can generate code. Organisations should strengthen scanning, secret detection, and release gating first, especially in identity-sensitive applications. Otherwise, AI tools simply amplify the volume of vulnerable code entering production.
Technical breakdown
Why AI-generated code passes tests but still fails security
Large language models are pattern matchers first and reasoning systems second. They are very good at producing code that resembles secure examples and satisfies syntax or unit-test expectations, but they often miss context-dependent security logic such as input validation, output encoding, and safe error handling. That is why common flaws can remain invisible until a security test or adversary finds them. The problem is structural: the model optimises for plausibility, not assurance.
Practical implication: security teams need controls that evaluate security properties separately from functional correctness.
Why XSS and log injection remain weak points for code models
Cross-site scripting and log injection are difficult for models because both depend on how data is handled across trust boundaries, not just whether the code compiles. These flaws require understanding data flow, sinks, and contextual encoding, which means the model must reason about what untrusted input becomes once it reaches a browser, log file, or downstream service. Pattern memory helps with obvious cases, but not with subtle propagation paths.
Practical implication: prioritise secure coding guardrails and automated scanning around untrusted-input handling paths.
How secure prompting and automated gates change the output
Secure prompting can steer a model toward safer patterns by making security constraints explicit at generation time. Automated build gates then add a second layer by blocking code that introduces critical findings before it reaches production. Together, they create a control stack that treats AI-generated code as untrusted until it has been verified. That is the practical shift from developer convenience to governed software delivery.
Practical implication: embed secure prompting, SAST, and dependency checks directly into the delivery pipeline.
Threat narrative
Attacker objective: The attacker aims to exploit code that was accepted as functional but not secured, turning trusted deployment pipelines into a path to application compromise.
- Entry occurs when insecure AI-generated code introduces exploitable logic into application codebases through normal development workflows.
- Escalation follows when attackers identify common flaws such as XSS, log injection, or weak input handling and use them to reach sensitive functions or data flows.
- Impact is realised when vulnerable code is deployed into production, enabling compromise of user sessions, data exposure, or downstream abuse of trusted application logic.
NHI Mgmt Group analysis
Software trust is becoming the real control plane for AI-assisted development. Traditional SDLC governance assumes developers can review output before risk is propagated, but AI coding tools compress the time available for review and remediation. That makes code assurance, not code generation, the strategic control point. The right question is no longer whether teams can write faster, but whether they can verify faster.
Security debt is now an identity-adjacent risk because application code increasingly governs authentication and authorisation paths. When insecure code is merged into systems that issue, validate, or broker access, the result is not just application vulnerability but identity control failure. That is why IAM teams should care about secure code pipelines, secret handling, and access-sensitive logic in the same governance conversation.
Secure prompting is emerging as a governance requirement, not a developer preference. If models generate insecure patterns by default unless constrained, then prompt policy becomes part of the control surface. This is where NIST CSF, secure SDLC discipline, and application guardrails intersect. Practitioners should treat prompting standards as a repeatable control, not a style guide.
Manual assurance alone cannot scale to AI-era code volume. The combination of high syntax correctness and weak security correctness means teams will keep merging risky output unless automated controls intervene earlier. Build-time scanning, policy gates, and evidence generation must become the default path for production software. That is how organisations turn AI speed into governed delivery instead of accumulated exposure.
Named concept: security trust gap. This post illustrates the widening gap between code that appears valid and code that can be trusted in production. For practitioners, the implication is straightforward: secure software governance now depends on proving security properties continuously, not assuming them at merge time.
What this signals
AI-assisted development changes the operational baseline for software governance. Security teams will need to assume that application code can arrive in production faster than human review can validate it, which makes build-time control enforcement and evidence generation more important than developer education alone. For teams managing identity-sensitive applications, this is where secure code governance begins to overlap with secrets handling, access control, and application trust boundaries.
Security trust gap: organisations should now measure the difference between code delivery speed and security verification speed. When the former rises while the latter stays flat, exposure accumulates quietly across every service that handles credentials, user sessions, or privileged application logic. That is a programme-level risk signal, not a local developer issue.
The practical signal for practitioners is whether their software pipeline can prove security posture continuously. If the answer depends on a weekly review, a manual sign-off, or a best-effort secure prompt, then the control model is already behind the threat model. Teams should prepare for tighter policy enforcement, more automation, and stronger audit evidence across development and release workflows.
For practitioners
- Treat AI-generated code as untrusted until verified Classify model output as provisional code and require automated security verification before merge. Use separate checks for functional correctness, secret detection, and security-sensitive data flows.
- Standardise secure prompting across developer toolchains Create prompt templates that explicitly constrain insecure patterns, especially in authentication, authorisation, input handling, and logging paths. Make the prompts part of engineering policy, not an optional habit.
- Gate production with automated security controls Use SAST, SCA, and build-time policy checks to block critical vulnerabilities before deployment. Manual review should support, not substitute for, automated enforcement in AI-assisted pipelines.
- Prioritise security debt in the most exposed applications Focus remediation on internet-facing, identity-heavy, and business-critical services first. Risk-based remediation is the only realistic way to absorb AI-generated code volume without expanding exposure.
- Track security correctness separately from code correctness Report security pass rate, not just test pass rate, as a delivery metric. If security outcomes lag while syntax scores rise, the pipeline is producing trusted-looking code that still increases risk.
Key takeaways
- AI-generated code now creates a measurable security trust gap because it often looks correct while still failing security tests.
- The evidence points to a pipeline problem, not just a developer problem, because speed is rising while secure verification lags.
- Organisations need secure prompting, automated gates, and risk-based remediation to stop AI-assisted delivery from becoming a breach amplifier.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
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 |
|---|---|---|
| NIST CSF 2.0 | PR.DS-6 | AI-generated code creates integrity risk in the software delivery pipeline. |
| NIST SP 800-53 Rev 5 | SI-2 | Security flaw introduction and remediation map to system flaw handling. |
| CIS Controls v8 | CIS-16 , Application Software Security | Application software security is the control area most directly affected by AI-generated code. |
| MITRE ATT&CK | TA0001 , Initial Access; TA0009 , Collection; TA0010 , Exfiltration | The article’s risk is exploitation of vulnerable application logic leading to compromise. |
Map exploitable code paths to ATT&CK tactics and prioritise controls around exposed application entry points.
Key terms
- Activation Trust Gap: The activation trust gap is the difference between trusting data because it is protected and governing it because it is being reused. It appears when organisations move data from backup or archival systems into AI pipelines without reapplying access, sensitivity, and consumer controls.
- Security Debt: Accumulated risk that builds when vulnerabilities, unsafe dependencies, and policy gaps are left unresolved across the software lifecycle. In AI-assisted development, security debt grows quickly because more code is produced, more decisions are made automatically, and remediation often lags behind delivery.
- Secure Prompting: Secure prompting is the practice of giving AI coding tools explicit constraints that steer output toward safer patterns. It is a governance control, not a style preference, because prompts can influence how models handle authentication, input validation, logging, and other security-sensitive behaviours.
- AI-assisted development: A development workflow where an AI system helps generate, refactor, test, or execute code inside the software delivery process. The security issue is not the assistance itself, but that the tool may operate in trusted contexts that also contain credentials, infrastructure access, and other sensitive assets.
What's in the full article
Veracode's full article covers the operational detail this post intentionally leaves for the source:
- Model-by-model security pass-rate breakdowns across the tested large language models
- Detailed comparison of secure prompting, manual review, and automated scanning outcomes
- The full State of Software Security framing behind Prioritize, Protect, and Prove
- Specific recommendations for integrating build gates and continuous verification into delivery pipelines
Deepen your knowledge
NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, machine identity security, and secrets management. It helps practitioners connect identity controls to the broader security workflows that modern software delivery depends on.
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