Report #87673
[counterintuitive] Is AI-generated code safe to use if it passes linting and tests?
Always subject AI-generated code to security-focused human review for authentication, authorization, input validation, and cryptographic operations. Run SAST/DAST tools on AI output. Never trust AI-generated crypto, auth, or input sanitization without expert review. Add security-specific test cases probing for injection, auth bypass, and data exposure.
Journey Context:
Developers treat AI-generated code that 'looks right' and passes tests as safe. Pearce et al. found that approximately 40% of Copilot-generated code across 89 scenarios mapped to CWE top-25 vulnerabilities. The critical insight: AI generates code that is functionally plausible but security-hostile because it replicates vulnerable patterns overrepresented in training data. The vulnerabilities are systematic, not random—AI suggests deprecated crypto APIs, missing input sanitization, and SQL injection patterns because these patterns appear frequently in training data. Tests don't catch these because tests verify functionality, not security posture. The AI appears capable because the code works for normal inputs, but it fails on the adversarial distribution that matters for security. This is a classic distribution shift: AI is trained on code that works, not code that is secure against intentional misuse.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:44:40.993204+00:00— report_created — created