AI Code Is Guilty Until Proven Secure: A Policy Framework for Teams
- Mark Chomiczewski
- 8 June 2026
- 0 Comments
Imagine your development team ships a new feature on Friday. It works perfectly. The tests pass. But by Monday morning, that code is being exploited because the AI assistant that wrote it used an outdated, vulnerable library pattern. This isn’t a hypothetical nightmare scenario; it’s the current reality for many teams adopting generative AI in software development. The speed at which AI-generated code is code written or suggested by large language models (LLMs) and integrated into software projects by developers enters production far outpaces our traditional security checks. To survive this shift, organizations must adopt a "guilty until proven secure" stance. This means treating every line of code produced by an AI as untrusted until it passes rigorous, explicit verification.
The Core Problem: Why AI Code Isn't Inherently Safe
We often assume that if a tool is advanced, its output is safe. That assumption is dangerous when applied to AI coding assistants. Research from the Center for Security and Emerging Technology (CSET) at Georgetown University found that nearly half of the code snippets generated by major AI models contained bugs. More importantly, these weren't just syntax errors; they were impactful vulnerabilities like missing input validation, weak authentication, and unsafe memory handling.
The problem stems from how Large Language Models (LLMs) work. They predict the next likely token based on training data. They don't "understand" security in the way a human engineer does. If their training data includes insecure patterns-which is common in open-source repositories-they will reproduce those patterns. Contrast Security notes that AI-generated code is not inherently more or less secure than human-written code, but the volume and speed at which it is produced expand the attack surface significantly. Without a formal policy, you are essentially letting an unvetted intern write critical infrastructure code, then hoping peer review catches everything.
Defining the Three Classes of AI Code Risk
To build an effective policy, you first need to understand what you are protecting against. CSET and industry experts categorize AI code risks into three distinct buckets:
- Insecure Code Generation: The AI outputs code with known vulnerabilities (e.g., SQL injection flaws, hardcoded credentials). This is the most immediate risk.
- Model-Level Threats: The AI model itself can be manipulated through adversarial prompt injection or poisoned training data, causing it to generate malicious code intentionally.
- Systemic Supply Chain Risks: Insecure AI-generated code gets merged into internal libraries or open-source projects, creating feedback loops where future AI models learn from this bad code, propagating vulnerabilities across the entire ecosystem.
A "guilty until proven secure" framework addresses all three by enforcing controls at the point of generation, during integration, and at runtime.
Building the Governance Layer: Policy and Accountability
Technology alone won't solve this. You need governance. Checkmarx’s 2025 guidance for CISOs emphasizes that layered governance controls are essential. Start by defining clear AI Code Usage Policies is formal organizational rules that dictate which AI tools are permitted, how they can be used, and what restrictions apply to the code they produce. These policies should specify:
- Permitted Tools: Which AI assistants are approved? Are there banned tools?
- Usage Contexts: Can AI be used for prototyping? For production code? For sensitive components like authentication or cryptography? (The answer for the latter should usually be no, or heavily restricted.)
- Identification Requirements: How do you mark AI-generated code in your repository? Transparency is key for auditors and reviewers.
- Review Mandates: Require mandatory peer review or automated security scanning for any commit containing AI-generated code.
Contrast Security advocates for a shared responsibility model. Developers, AppSec teams, and DevOps must share ownership. Developers must be trained to critically evaluate AI suggestions, not just copy-paste them. Security teams must adapt their tooling to handle the increased volume of code changes.
Technical Controls: Integrating Security into the Workflow
Policies mean nothing without enforcement. You need technical controls embedded directly into the developer workflow. This involves integrating security tools into IDEs, CI/CD pipelines, and runtime environments.
| Control Type | Function | Example Tools/Approaches |
|---|---|---|
| Static Application Security Testing (SAST) | Scans source code for vulnerabilities before compilation. | Checkmarx, SonarQube, integrated IDE plugins |
| Software Composition Analysis (SCA) | Checks dependencies for known vulnerabilities and license issues. | Snyk, Black Duck, Dependabot |
| Policy Engines | Enforces custom security rules defined in natural language or code. | ZeroPath, OPA (Open Policy Agent) |
| Runtime Application Self-Protection (RASP) | Monitors and blocks attacks in real-time during execution. | Contrast Security, Imperva |
| Secure-by-Default Rulesets | Pre-configured security rules for AI agents to follow. | Cisco Project CodeGuard |
Cisco’s Project CodeGuard is a notable example of a framework designed to build secure-by-default rules into AI coding workflows. It provides validators that enforce security rules automatically as code is generated. Similarly, ZeroPath allows organizations to define custom security rules in natural language, translating them into machine-enforceable policies. These tools help automate the "proven secure" part of the equation, reducing the burden on manual reviewers.
Aligning with NIST AI RMF
For enterprise teams, aligning your AI code security efforts with established frameworks adds credibility and structure. The NIST AI Risk Management Framework (AI RMF) is a voluntary, organization-level framework developed by NIST to manage risks associated with AI systems throughout their lifecycle provides a robust scaffold. Its four core functions-Govern, Map, Measure, and Manage-map well to AI code security:
- Govern: Establish roles, responsibilities, and policies for AI code usage. Define who approves AI tools and who reviews AI-generated code.
- Map: Identify where AI is being used in your SDLC. Track which repositories contain AI-generated code and how it flows into production.
- Measure: Quantify risk. Use metrics like vulnerability density in AI-generated code vs. human-written code, time-to-remediation, and the percentage of code covered by automated security scans.
- Manage: Implement controls to mitigate identified risks. This includes deploying SAST/DAST tools, enforcing code review gates, and providing developer training.
NIST explicitly recommends leveraging existing secure software development practices for all code, regardless of authorship. This reinforces the idea that AI code doesn't get a free pass; it must meet the same high standards as human-written code.
Cultural Shift: Training and Mindset
Tools and policies fail if the culture doesn't support them. Developers need to understand *why* AI code is treated as guilty until proven secure. Training programs should cover:
- How LLMs Work: Explain that AI predicts text, it doesn't reason about security implications.
- Common AI Pitfalls: Show examples of insecure patterns AI frequently generates (e.g., insecure random number generation, missing authorization checks).
- Validation Techniques: Teach developers how to scrutinize AI suggestions, particularly around data handling, input validation, and privilege boundaries.
ArmorCode notes that mature teams foster shared ownership of security outcomes. When developers feel empowered to question AI suggestions and know that security tools are there to help rather than hinder them, adoption improves. Avoid governance paralysis by starting small-focus on high-risk areas first, then expand coverage incrementally.
Implementation Roadmap for Teams
Rolling out a "guilty until proven secure" framework doesn't happen overnight. Here’s a practical step-by-step approach:
- Discovery: Use automated tools to discover where AI tools are currently being used in your codebase. Understand your AI footprint.
- Policy Drafting: Collaborate with legal, compliance, and security teams to draft initial AI code usage policies. Define prohibited use cases (e.g., crypto modules).
- Tool Integration: Integrate SAST, SCA, and policy engines into your CI/CD pipeline. Set up IDE plugins for real-time feedback.
- Pilot Program: Run a pilot with a small team. Test the policies and tools, gather feedback, and adjust thresholds to reduce false positives.
- Training & Rollout: Train developers on the new processes and tools. Expand the program organization-wide.
- Continuous Monitoring: Regularly review metrics, update policies, and refine technical controls based on emerging threats and lessons learned.
Expect a timeline of 3-6 months for a basic pilot and 12-18 months for full organizational maturity. The goal is not perfection from day one, but continuous improvement.
Is AI-generated code less secure than human-written code?
Not necessarily less secure, but it carries different risks. AI models can reproduce insecure patterns from their training data. The primary issue is scale and speed: AI produces code faster than humans can manually review it, increasing the likelihood of vulnerabilities reaching production if automated checks are insufficient.
What is the "guilty until proven secure" principle?
It is a zero-trust security stance where all AI-generated code is treated as untrusted by default. It must pass explicit security verification-such as automated scanning and peer review-before it can be merged into the main codebase or deployed to production.
Which tools can help enforce AI code security policies?
Tools include Static Application Security Testing (SAST) scanners like Checkmarx or SonarQube, Software Composition Analysis (SCA) tools like Snyk, policy engines like ZeroPath or Open Policy Agent, and specialized frameworks like Cisco’s Project CodeGuard. Runtime protection tools like Contrast Security are also valuable for catching issues that slip through pre-deployment checks.
How does NIST AI RMF relate to AI code security?
The NIST AI Risk Management Framework provides a structured approach to managing AI risks. Its Govern, Map, Measure, and Manage functions help organizations establish policies, track AI usage, quantify risks, and implement controls for AI-generated code, ensuring alignment with broader security and compliance goals.
Should I ban AI-generated code in certain parts of my application?
Yes. Most security experts recommend prohibiting or heavily restricting AI-generated code in sensitive components such as authentication, authorization, cryptography, and financial transaction logic. These areas require deep contextual understanding and rigorous validation that current AI models may lack.