The Problem: AI Code Generators Skip Security

▶ Watch (1:28)

Sean Sinclair noticed that AI-generated code consistently missed security basics. API keys appeared in plain text. Rate limiting was absent. Models like GPT-3.5 and GPT-4 repeated the same insecure patterns. The training data included insecure code from Stack Overflow, so AI learned the fast path, not the safe one. Developers copy-paste and ship. The result is code that passes functional tests but fails security reviews.

Three-Word Prefix Lifts Pass Rates by 15%

▶ Watch (26:16)

Sinclair ran two experiments using 300 unique prompts, generating 3,000 code samples. Standard prompts passed the LLM-as-a-judge evaluation 68% of the time. Prompts prefixed with using best practices passed 83.4% — a 15.3% average increase. The first experiment used GPT-4o mini on 200 prompts; pass rate rose from 70% to 86.7%. The second tested GPT-4o mini, GPT-5 mini with reasoning, and GPT-5.1, confirming the pattern.

Live Demo: Promptfoo Evaluates Three Models

▶ Watch (20:49)

Sinclair demonstrated Promptfoo, an open-source LLM testing framework. He configured evaluations with Gemini 1.5 Pro, Claude Opus, and GPT-3.5 Codex. The standard set scored 40% passes; the secure set scored 60% — still a 20% gain. The web interface let him inspect each response: a Claude Opus pass used bcrypt and parameterized queries; a GPT-3.5 Codex fail hardcoded database credentials. The tool runs in CLI and CI/CD pipelines.

Model Choice Matters More Than Prompt Length

▶ Watch (33:09)

GPT-4o mini averaged 42% pass rate across all tests. GPT-5.1 reached 82%, and GPT-5 mini with reasoning hit 95% but consumed 4,900 tokens per query. Adding using best practices improved every model. The biggest jump came from moving to a better model, not from longer prompts. Sinclair argued that short prompts avoid instruction drift and expensive reasoning tokens on simple tasks. Reasoning models think harder, which helps security but costs more.

Practical Prompt Hardening Tips

▶ Watch (43:06)

Sinclair recommended three actions. First, use AI to analyze your project and generate system instructions via slash init in tools like Claude Code. Second, skip generic tips and focus on your specific tech stack. Third, review and document prompt versions to avoid regression. He stressed that using best practices is not a silver bullet. Developers must still verify output, use the right model, and maintain system prompts. Security-focused agent skills are the next frontier.

Notable Quotes

the age-old saying of crap in, crap out. Sean Sinclair · ▶ Watch (4:26)

code security just by adding three words. Sean Sinclair · ▶ Watch (26:56)

Using best practices is good, but it’s not perfect. Sean Sinclair · ▶ Watch (44:16)

Key Takeaways

  • Adding “using best practices” raised pass rates by 15.3%.
  • Model choice impacted security more than prompt length.
  • Short prompts reduce instruction drift and token waste.
  • Promptfoo enables systematic AI code security evaluation.

About the Speaker(s)

Sean Sinclair is an application security engineer at Equinor. His background includes software development and game programming. He focuses on AI and security, digging into systems to find what breaks and how to improve them. Outside work, he is a hobby game developer and kitchen nerd.