
Daily Digest
Put security rules in coding prompts
A fixed security paragraph helps. A scope line stops extra packages.
The problem
When you ask an AI coding tool to "build a small web app," it quietly makes the security choices for you: whether forms resist forged submissions, whether login cookies are locked down, whether the browser gets safety headers. If you don't ask, much of that gets left out, and nobody looks at the defaults until something goes wrong.
The technique
Add one fixed security paragraph to every build request. It covers basics like parameterised queries, password hashing, CSRF protection, secure cookies, security headers and no secrets in code. A study posted Nov 20 found that it cuts findings but pulls in extra packages. The author's suggested fix, which the study did not test, is to scope the request and name the libraries. We tested that too, with one extra scope line: add only the protections this app needs, prefer Flask and the standard library, pin any added package.
How it works
From request to result, in 5 steps
Step 1 of 5
You ask for an app
You describe what the app should do. Most people say nothing about safety, so the AI picks the safety settings for you.
Step 2 of 5
Add the safety rules
We sent each request three ways: A plain, B with one fixed safety paragraph, and C with that paragraph plus one scope line: only what this app needs, Flask first, pin anything extra.
Step 3 of 5
The AI builds it
Each AI model wrote the app and a list of the packages it needs. 12 app ideas, 3 versions, 3 models: 108 apps in all.
Step 4 of 5
We check what's inside
We looked for form protection and safety headers in the code, counted extra packages, checked each one exists, then started the app.
Step 5 of 5
What happened
On both Claude models, the paragraph added the protections and the scope line removed the extra packages. The small local model got worse with help.
What we saw
The study built 100 app specs twice each with Claude Code and Codex CLI, once plain and once with a fixed OWASP paragraph. Across 400 scanned apps, the paragraph cut reported findings per app by about a third (35% for Claude Code, 31% for Codex), and serious findings in the apps' own code fell from 103 to 54. The catch: the apps' direct dependencies roughly doubled (3.2 to 6.3 per app for Claude Code), which brought more package advisories. Those are their numbers.
Our own check was much smaller: 12 small Flask app specs (6 with user accounts, 6 without), given to Claude Haiku 5.5 and Claude Sonnet 5.5 at low effort through Claude Code, and to Qwen 2.5 3B running locally (4-bit, llama.cpp, greedy, no effort setting), in three versions: plain, with the paragraph, and with the paragraph plus the scope line. That is 108 apps. With the plain request, Sonnet added CSRF protection to 5 of 12 apps and safety headers to 4; Haiku managed 2 and 0. With the paragraph, both Claude models added both to all 12. The side effect showed up too: 10 to 11 of 12 apps gained an extra package, and 4 to 5 of the 6 apps with no accounts got password-hashing code anyway. The scope line fixed that on both Claude models: no extra packages beyond Flask's own in any of the 24 apps and no password code in apps without accounts, while safety headers stayed at 12 of 12 and CSRF protection at 10 to 11 of 12. All 24 of those apps started and answered a request. The small local model did worse with help. The paragraph pushed it to 4.5 extra packages per app, and 6 of 12 apps listed package names that do not exist on PyPI. Only 1 of 12 of those apps started.
Our test, 108 apps
What each version did, out of 12 apps
Claude Sonnet 5.5
The paragraph added both protections to all 12 apps, but 10 of 12 picked up an extra package. The scope line kept the protections and took the extra packages away.
Form protection (CSRF) more is better
Browser safety headers more is better
Asked for an extra package fewer is better
Added password code to apps with no logins fewer is better
Asked for a package that doesn't exist fewer is better
App started and answered more is better
Extra packages per app: 0 plain, 1 with the paragraph, 0 with the scope line.
Claude Haiku 5.5
Plain, it added form protection to only 2 of 12 apps and safety headers to none. The paragraph got both to 12 of 12. The scope line removed the extra packages and kept safety headers at 12 of 12.
Form protection (CSRF) more is better
Browser safety headers more is better
Asked for an extra package fewer is better
Added password code to apps with no logins fewer is better
Asked for a package that doesn't exist fewer is better
App started and answered more is better
Extra packages per app: 0 plain, 0.92 with the paragraph, 0 with the scope line.
Qwen 2.5 3B, a small model run on our own machine
Help made it worse. With the paragraph, 6 of 12 apps asked for packages that don't exist, and only 1 of 12 started. Check every package a small local model lists.
Form protection (CSRF) more is better
Browser safety headers more is better
Asked for an extra package fewer is better
Added password code to apps with no logins fewer is better
Asked for a package that doesn't exist fewer is better
App started and answered more is better
Extra packages per app: 0.92 plain, 4.5 with the paragraph, 1.67 with the scope line.
Each dot is one app. We checked that each protection is in the code, not that it holds up under attack. “Extra package” means one beyond Flask and its own Werkzeug.
Limits
Twelve specs, one run each, Python and Flask only, single-file apps. We checked whether protections were present in the code, not whether they hold up under attack, and we did not run the paper's dynamic scans. A code scanner (bandit) flagged almost nothing in any version (under 0.5 findings per app), so our gain shows in protections added, not in scanner counts. The paragraph also made Claude's code 1.7 to 2.1 times longer. The scope line is our wording, tested only here. Don't use this on small local models without checking every package they list.
Try it
Paste the security paragraph and the scope line into the rules file your coding agent reads on every task. After each build, read the requirements file: every package should be one you would have picked, and each one should actually exist before you install it.
Models tested
- Claude Haiku 5.5 (claude-haiku-5-5) via Claude Code CLI 2.1.330, effort low, no tools, one shot per app
- Claude Sonnet 5.5 (claude-sonnet-5-5) via Claude Code CLI 2.1.330, effort low, no tools, one shot per app
- Qwen 2.5 3B Instruct Q4_K_M (llama.cpp, greedy, max 1800 tokens)
Sources
Did it work for us?
Worked
On both Claude models the paragraph added the missing protections and the scope line removed the extra packages; a small local model got worse with it.