Security flaws in generated code
For engineers
The vulnerability classes AI assistants write most often: injection, missing authorization, leaked secrets, trusted input and unsafe defaults
110 questions across four stages: Understand, Apply, Solve and Judge.
Try 5 questions
Practice items, not counted towards your mastery. No account needed.
Check yourself · 1 of 5
An AI assistant builds a query with an f-string that includes a request parameter. What is the correct fix?
Check yourself · 2 of 5
A generated endpoint has a login middleware and returns an invoice by id from the URL. What is still missing?
Check yourself · 3 of 5
An AI-written feature fetches any URL the user types and returns the page text. Which attack does this allow?
Check yourself · 4 of 5
An AI agent committed an API key, and you removed it in the next commit. What else is required?
Check yourself · 5 of 5
A browser blocks a call from https://app.example.com to your API. Which CORS setting is the right fix?
Topics
- Injection in AI-written queries and commands4 min read · SQL, shell, template and path injection from string-built queries and commands that models still produce
- Missing authorization and broken access control4 min read · Endpoints that check login but not ownership, insecure direct object references and admin routes without role checks
- Trusting input: SSRF, uploads and deserialization4 min read · User-controlled URLs, files and payloads that generated code fetches, stores or parses without validation
- Hardcoded secrets and credential leaks4 min read · Keys in code, config, test fixtures, logs and agent transcripts, and how secret scanning and rotation fix them
- Unsafe defaults: CORS, debug mode and crypto4 min read · Wildcard CORS, debug flags, disabled TLS verification, weak hashing and broad permissions that make demos work
- Asking coding agents for secure code4 min read · Security requirements in the task, a threat-focused second review pass, and why 'make it secure' is not enough
Start here
- CWE Top 25 Most Dangerous Software Weaknesses (MITRE) (opens in a new tab)DocsFree
The ranked list of weakness classes, including injection and broken access control, that generated code should be checked against.
- Do Users Write More Insecure Code with AI Assistants? (opens in a new tab)PaperFree
A user study showing assistant users wrote less secure code while feeling more sure of it.
- OWASP Top Ten (opens in a new tab)StandardFree
The standard awareness list of web application risks, from access control to misconfiguration.
Scenarios
Helps to know first
110 questions · last verified 2026-12