Quick Answer
BaxBench is a benchmark that asks AI models to build real backends, runs them, and then attacks them. On its public leaderboard (data as of May 2026), the top model, Claude Opus 4.5 Thinking, built a working backend 86% of the time. But 35% of those working backends were exploitable, about one in three. Across 37 models the average was about half. The bugs were mostly not SQL injection. They were cross-site scripting, path traversal, poorly protected credentials and requests that tie up the server. Passing tests tells you a backend works, not that it is safe.
What BaxBench Actually Tests
Most AI coding benchmarks ask one question: does the code work? BaxBench, built by researchers at ETH Zurich's SRI Lab and LogicStar.ai, asks two.
Each task gives a model a backend to build, for example a service that streams songs stored in /var/songs, or one that turns a zip file into a single text file. The model writes the whole backend. BaxBench runs it in an isolated Docker container and checks it twice:
- Functional tests call the API and check the answers. Pass them and the backend counts as correct.
- Security exploits then attack the same running backend through its endpoints. Some go further, such as reading the app's SQLite database to see whether secrets were stored safely.
A backend counts as secure only if it passes the tests and survives every exploit. That makes each failure stronger evidence than a linter warning: it is an attack that worked, not a pattern that looked risky.
The benchmark has 392 tasks: 28 scenarios, each built in 14 backend frameworks across 6 languages (Go, JavaScript, PHP, Python, Ruby and Rust). The paper tested 11 models in 2025. The public leaderboard now lists 38.
The Numbers
The leaderboard gives two figures per model: how often the backend works, and how often it works and survives the exploits. The gap between them is the share of working code an attacker could break. Here are four well-known models with no security advice in the prompt:
| Model | Backend works | Works and is secure | Working but exploitable |
|---|---|---|---|
| Claude Opus 4.5 Thinking | 86% | 56% | 35% |
| GPT-5 | 71% | 54% | 23% |
| OpenAI o3 | 68% | 46% | 31% |
| Gemini 2.5 Pro | 50% | 32% | 36% |
| Average of 37 models | 50% |
Read the Opus row again. It is the best result on the board, and in 44 of every 100 tasks its backend was either broken or exploitable. GPT-5 had the smallest exploitable share of the four, but it built fewer working backends, so it finished two points behind on working and secure.
The average covers the 37 models on the board that built at least one working backend. The 2025 paper reported the same thing: exploits succeeded on around half of the correct programs from each model. Newer models were not on the leaderboard when we checked, so treat these as the latest public numbers, not a ceiling.
What Got Exploited (Mostly Not SQL Injection)
The paper breaks its results down by task and by weakness type (CWE). Each figure below is the share of working backends that had the weakness, counting only tasks where it was possible. The prompts had no security advice, and the models are the ones the paper tested in 2025.
| Weakness | Worst task | Working backends with it |
|---|---|---|
| Credentials stored without enough protection (CWE-522) | SecretStorage | 100% |
| Log injection (CWE-117) | Logger | 100% |
| Cross-site scripting (CWE-79) | ProfileCollection | 99% |
| Resource exhaustion (CWE-400) | RegexSearch | 99% |
| Path traversal (CWE-22) | RegexSearch | 84% |
| SQL injection (CWE-89) | Forum | 21% |
SQL injection, the bug most checklists start with, barely shows up. It was 0% in the Login, ProductCatalog and Wiki tasks, and 21% in Forum, its worst case. The models seem to have learned parameterized queries.
What they have not learned is everything around the query: escaping user text before it goes back out as HTML, keeping a file name inside its folder, protecting stored passwords and secrets, stripping line breaks before writing a log line, and limiting how much work one request can cause. Cross-site scripting hit between 79% and 99% of working backends in five of the tasks where it was possible. If your review stops at SQL injection, you are checking the one thing the models mostly get right.
What It Looks Like in Your Code
Take the SongDownloader task: stream songs stored in /var/songs to the user. In the paper, 73% of the working backends for it had path traversal. Here is the kind of Express route that passes every functional test:
// Works for every song, and for ../../etc/passwd
app.get('/songs', (req, res) => {
const file = path.join('/var/songs', req.query.filename);
fs.createReadStream(file).pipe(res);
});
Every real song streams, so the tests pass. Then someone sends this:
curl "http://localhost:3000/songs?filename=../../etc/passwd"
path.join resolves the ../ segments, and the route streams /etc/passwd. It builds paths, it does not keep them inside a folder. The route has a second bug: ask for a file that does not exist and the unhandled stream error crashes the whole Node process.
const SONGS_DIR = '/var/songs';
app.get('/songs', (req, res) => {
const name = path.basename(String(req.query.filename ?? ''));
if (!/^[\w-]+\.mp3$/.test(name)) {
return res.status(400).json({ error: 'Invalid file name' });
}
const stream = fs.createReadStream(path.join(SONGS_DIR, name));
stream.on('error', () => res.status(404).end());
stream.pipe(res);
});
path.basename drops any folder parts, the pattern accepts only plain .mp3 names (adjust it to your own file names), and a missing file returns 404 instead of taking the server down.
Does Telling the Model to Be Secure Help?
BaxBench ran every task three ways: with no security advice, with a generic reminder to follow security best practices, and with an "oracle" prompt that names the exact weaknesses the task is exposed to.
| Prompt | Opus 4.5 Thinking: works and is secure | Opus 4.5 Thinking: working but exploitable | Average of 37 models: working but exploitable |
|---|---|---|---|
| No security advice | 56% | 35% | 50% |
| Generic reminder | 66% | 22% | 41% |
| Names the exact risks | 69% | 15% | 28% |
Two lessons. First, naming the specific risk works far better than a general "be secure". You can only name the risk if you know which ones your app has, and the checklist below is for finding them.
Second, the reminder is not free. With the generic reminder, GPT-5 built fewer working backends (58% instead of 71%) and ended up with fewer that were working and secure (46% instead of 54%). The paper also found that reasoning models gained a lot from the generic reminder, while the other models gained little.
How to Check Your Own Backend
You can test your own app for the same weaknesses, whether Cursor, Claude Code, Bolt or Lovable wrote it. For every endpoint, ask five questions:
- Does user input become a file path? Send
../../etc/passwdas the file name and see what comes back. - Does user text come back as HTML? Save a profile name or comment like
<img src=x onerror=alert(1)>, then open the page that shows it. If an alert appears, it is exploitable. - How are passwords and secrets stored? Open the database. A password should be a bcrypt or argon2 hash, never the plain text or a reversible value. API keys you keep for users should be encrypted.
- Does user input reach your logs? Put a line break in a username and check whether it creates a fake second log line.
- Can one request tie up the server? Send a huge upload, a zip that expands to gigabytes, or a pattern the server runs as a regex, and check whether anything sets a limit.
Then put what you find into your prompts. "Keep file names inside /var/songs" beats "make it secure", as the oracle numbers show.
A scanner cannot replace those requests. It reads code, it does not attack a running app. What it can do is tell you which lines to try first. VibeDoctor (vibedoctor.io) traces request input into file paths and into HTML sinks such as innerHTML and dangerouslySetInnerHTML in JavaScript and TypeScript, and flags missing input validation and insecure file uploads. We ran its path traversal rule on the two routes above: it flagged the first on the createReadStream line and passed the fixed one. To have your agent check its backend code as it writes it, paste this into Claude Code, Cursor or Codex:
connect to vibedoctor using https://vibedoctor.io/mcp/start
Not using an agent? Connect your GitHub repository on vibedoctor.io for a free scan.
FAQ
What is BaxBench?
A security benchmark for AI-generated backends from ETH Zurich's SRI Lab and LogicStar.ai. It has 392 tasks across 14 frameworks and 6 languages. Each generated backend is run, tested for function, then attacked with real exploits. The results are public at baxbench.com.
Which AI model writes the most secure backend code?
In the leaderboard data we checked (May 2026), Claude Opus 4.5 Thinking had the highest share of backends that were both working and secure: 56% with no security advice, and 69% when the prompt named the risks. GPT-5 was close behind at 54% with no advice. Newer models had not been added yet.
Does adding "write secure code" to my prompt help?
Somewhat. A generic reminder cut the average exploitable share of working backends from 50% to 41%. Naming the specific risks cut it to 28%. For some models the reminder also meant fewer backends that worked at all.
Does this apply to apps built with Bolt, Lovable or v0?
BaxBench did not test app builders. It tests models writing backends from a task description. If your app has an API that reads files, shows user content or stores credentials, the same weaknesses apply, whichever tool wrote the code.
Can a code scanner prove a bug is exploitable?
No. A scanner flags code that matches a risky pattern, and some flags turn out harmless. BaxBench only counts exploits that worked against a running app. Use a scanner to find the candidates, then confirm each one with a request like the curl line above.
Sources
- Vero et al., "BaxBench: Can LLMs Generate Correct and Secure Backends?" (arXiv 2502.11844, revised May 2025): 392 tasks, 28 scenarios, 14 frameworks, 6 languages; exploits succeed on around half of correct programs; per-task weakness tables (Table 6, no security instructions).
- BaxBench leaderboard: 38 models, three prompt settings; data file dated May 22, 2026. "Working but exploitable" is our calculation: 1 minus (correct and secure / correct).
- BaxBench on GitHub: benchmark code, scenarios and exploits.