Phase 5: Security Testing AI-Generated Code · 55 min · Z3 SMT solver · GCC AddressSanitizer · Python
The 55% Vulnerability Problem
55.8% of AI code has Z3-proven vulnerabilities. No model passes grade D.
Real-world application: Engineers who can cite the Z3 SMT verification study and explain why 55.8% of AI code is exploitable demonstrate awareness of the scale of AI security problems.
What you will learn
- Cite the Z3 SMT verification study: 55.8% vulnerability rate across 3,500 artifacts from 7 models
- Explain how Z3 satisfiability witnesses provide mathematical proof of exploitability
- Understand the model grading system: GPT-4o at 62.4% (grade F), Gemini 2.5 Flash at 48.4% (grade D)
- Explain how 6/7 Z3-proven vulnerabilities were confirmed with GCC AddressSanitizer runtime crashes
Introduction
The 55% Vulnerability Problem
Objective
Run the Z3 SMT verification simulation on AI-generated code artifacts. Observe the 55.8% vulnerability rate, model grading, AddressSanitizer confirmation, and the 97.8% gap between Z3 and industry tools.
55.8% of AI code has Z3-proven vulnerabilities. No model passes grade D.
The Problem
A landmark study analyzed 3,500 AI-generated code artifacts from 7 different models using Z3 SMT solvers for formal verification. The results are staggering: 55.8% of AI-generated code contains formally proven vulnerabilities. Not suspected, not heuristic-detected -- mathematically proven exploitable via Z3 satisfiability witnesses. 1,055 artifacts were confirmed exploitable, and 6 out of 7 were independently verified with GCC AddressSanitizer runtime crashes.
No model achieved grade C or better. The best performer (Gemini 2.5 Flash) scored 48.4% vulnerability rate -- grade D. The worst (GPT-4o) scored 62.4% -- grade F.
The Z3 SMT verification methodology
| Step | What happens | Why it matters |
|---|
| 1. Generate | 7 models generate 3,500 code artifacts | Diverse AI code samples |
| 2. Parse | COBALT pipeline parses code into formal representations | Machine-readable analysis |
| 3. Verify | Z3 SMT solver checks for satisfiability of exploit conditions | Mathematical proof |
| 4. Witness | Z3 produces a satisfiability witness (concrete exploit input) | Reproducible proof |
| 5. Confirm | GCC AddressSanitizer runs the exploit input | Runtime confirmation |
Model Grades
| Model | Vulnerability Rate | Grade |
|---|
| GPT-4o | 62.4% | F |
| Claude 3.5 Sonnet | 58.2% | F |
| DeepSeek Coder | 54.7% | D |
| Gemini 2.5 Flash | 48.4% | D |
| Llama 3.1 | 51.3% | D |
| Mixtral | 56.8% | F |
| Qwen 2.5 | 57.9% | F |
Why Z3 formal verification matters
Traditional security tools (SAST, SCA) use heuristic pattern matching -- they look for known vulnerability patterns. Z3 SMT solvers use mathematical proof -- they encode the code's behavior as formal constraints and check if an exploit input exists that satisfies those constraints. This means Z3 can find vulnerabilities that no SAST tool detects, because it's not pattern-matching -- it's proving. The study found that 6 industry tools combined catch only 7.6% of Z3-proven vulnerabilities. Z3 catches 100% of what it proves. This is the difference between guessing and knowing.
The Z3 study found that 6 industry security tools combined catch only 7.6% of Z3-proven vulnerabilities. What does this 97.8% gap mean for AI code security?
The 97.8% gap means that 92.4% of Z3-proven vulnerabilities are invisible to industry security tools. Industry tools (SAST, SCA) use heuristic pattern matching -- they look for known vulnerability patterns (SQL injection, XSS, buffer overflow). Z3 uses mathematical proof -- it encodes the code's behavior as formal constraints and checks if an exploit input exists that satisfies those constraints. This means Z3 finds vulnerabilities that SAST tools fundamentally cannot detect, because SAST is pattern-matching while Z3 is proving. For AI-generated code, this gap is critical because AI introduces novel vulnerability patterns (CWE-1236 incorrect escaping at 50.7%, CWE-916 broken crypto at 43.1%) that SAST tools don't have rules for. The fix: combine multiple layers -- SAST (catches known patterns, fast), Z3 formal verification (catches all provable vulnerabilities, slower), and AI review (catches novel patterns, contextual). No single tool is sufficient. The multi-layer approach is covered in Lesson 6."
This lesson is free
You've read the first 3 sections. The rest covers The Concept, Build, Check Yourself, Key Terms & Next. A free account opens all of it, with its practice questions and its lab. No card.
Create a free account — the opening phases of 29 of 35 courses, and the first lesson of every phase, are free, no credit card.
Browse all courses · View pricing · DeVenture Academy