BaxBench: Can Large Language Models Generate Correct and Secure Backends?BaxBench: Can LLMs Generate Correct and Secure Backends?
The authors propose the backend code generation benchmark BaxBench (392 tasks); across 11 LLMs, the highest sec_pass@1 is only 35% (OpenAI o3-mini).
- Existing code benchmarks mostly remain at the function level and test correctness and security separately, and cannot answer whether LLMs can generate deployable, correct and secure complete backend applications.
- Constructing BaxBench: 28 backend scenarios × 14 frameworks (6 languages) form 392 tasks, with framework-agnostic functional tests verifying correctness and expert-written end-to-end exploits actually attacking the generated backends to determine security.
- Among the 11 models, OpenAI o1 has a pass@1 of 62%, and the highest sec_pass@1 is 35% for OpenAI o3-mini; the authors state that about half of the programs that pass tests for each model can be attacked by exploits, and the proportion that is both correct and secure further declines on low-resource frameworks.
- The authors state that more exploits, test cases, frameworks and scenarios can be added, and note that benchmark contamination may occur after public release; reasoning models were sampled only 1 time per task, so pass@5 cannot be computed.
- Evaluated models
- OpenAI o1OpenAI o3-miniGPT-4oClaude-3.5 SonnetDeepSeek-R1DeepSeek-V3CodestralQwen2.5 CoderLlama-3.3 70BQwen2.5 72BQwen2.5 7B
- Benchmarks
- BaxBench
- Metrics
- pass@1sec_pass@1pass@5sec_pass@5
Researchers from ETH Zurich and other institutions release the BaxBench benchmark, comprising 392 tasks made up of 28 backend scenarios and 14 frameworks, to evaluate the ability of large language models to generate correct and secure backend applications, finding that the correct-and-secure generation rate of flagship models does not exceed 37%. The benchmark uses functional tests to check correctness and expert-written end-to-end exploits rather than static analysis to check security, covering 13 CWE categories, 9 of which are in the MITRE Top 25. Evaluation of 11 mainstream models shows that the highest-accuracy model, OpenAI o1, has a pass@1 of only 62%, about half of the correct programs generated by each model on average can be successfully exploited, and the highest sec_pass@1, OpenAI o3-mini, is only 35%. Models perform worse on lower-resource frameworks such as Rust-Actix and PHP-Lumen; general security prompts can markedly improve the security performance of reasoning models, and replacing plain-text descriptions with OpenAPI specifications can improve accuracy.
Why it was selectedThe benchmark uses expert-written end-to-end exploits instead of static analysis to check code security, and provides quantitative results showing that about half of each model's correct backends can be exploited.
Related events and news
1 events · 1 news mentions
News that mentions this paper
Hirundo研究称Qwen3-Coder为北京对手生成更脆弱代码
- Hirundonames the paperHirundo 案例研究称 Qwen3-Coder 为北京的对手编写更脆弱的代码,移除 CCP 对齐后差距消失
The task comes from BaxBench, an open benchmark from ETH Zurich and LogicStar that runs every app and attacks it with ready-made exploits.
Paper analysis
What problem does this paper attempt to solve?
Existing code benchmarks cannot answer whether LLMs can generate correct and secure complete backends; the authors propose BaxBench to fill this gap.
Core question: Can LLMs end-to-end generate deployable, functionally correct and secure backend applications? Existing benchmarks cannot measure this.
- Scenario and motivation: The authors consider backends a core component of modern web and cloud software; implementation requires spanning multiple functions and multiple files, and backends are directly exposed to untrusted third parties, so a single exploit can affect all users; therefore security is a prerequisite for deployment.
- Shortcomings of existing benchmarks: The authors point out that most benchmarks only test function-level completion or bug fixing, and are saturating (e.g., Claude-3.5 Sonnet exceeds 92% on HumanEval); SWE-Bench-style benchmarks target agents and mix in capabilities unrelated to code generation such as tool use; safety evaluations are often conducted separately from correctness, or cover only a single function or a single CWE.
- Core observation: The authors believe that only by testing functional correctness and practical exploitability simultaneously on the same set of complete applications can real deployment risk be reflected; static analysis tools have false positives and false negatives, so the authors instead use exploits that can actually be executed.
- What the paper proposes: The BaxBench benchmark—28 backend scenarios × 14 frameworks (6 languages), 392 tasks in total, using functional tests to verify correctness and expert-written end-to-end exploits to verify security, with 11 LLMs evaluated.
- This is not an attack/defense paper: It does not involve an attacker threat model; security testing is performed by exploits written by the benchmark authors, executed in isolated Docker environments, and the victim is the LLM-generated backend code itself.
What related research exists?
Related work is divided into three groups: functional benchmarks, security benchmarks, and cybersecurity capability evaluations; the authors state that BaxBench differs in both task form and security coverage.
Functional correctness benchmarks
- HumanEval (Chen et al., 2021), MBPP (Austin et al., 2021b), APPS (Hendrycks et al., 2021) — short algorithm-level code generation tasks; the authors note that such benchmarks are rapidly saturating.
- DS-1000 (Lai et al., 2023), Sketch2Code (Li et al., 2024a), ODEX (Wang et al., 2023), BigCodeBench (Zhuo et al., 2024) — domain-specific or open-domain benchmarks; the authors note that they cover only front-end design or at most single-function tasks, and do not perform safety evaluation.
- SWE-Bench (Jimenez et al., 2024), RepoBench (Liu et al., 2024b), SWE-Lancer (Miserendino et al., 2025) — generate patches, snippets, or implementation plans in repository context; the authors note that BaxBench generates complete applications from scratch.
Code security benchmarks
- AsleepAtKeyboard (Pearce et al., 2022a), SecurityEval (Siddiq & Santos, 2022), SafeCoder (He et al., 2024), CodeLMSec (Hajipour et al., 2024), CyberSecEval (Bhatt et al., 2023), CodeGuard+ (Fu et al., 2024), SecCodePLT (Yang et al., 2024b), CWEval (Peng et al., 2025) — secure code generation evaluation. The authors state that BaxBench differs from them in three respects: it proceeds top-down from real-world scenarios, and each scenario often contains multiple CWEs (in contrast to the bottom-up approach of constructing tasks around a single CWE); tasks involve multiple functions and multiple files (in contrast to single-function outputs); and it focuses on the security-critical domain of backends.
- The authors also note that some security evaluations rely on static analyzers (e.g., Fu et al., 2024; He et al., 2024), and cite research stating that static analysis has false positives and false negatives, is often a paid service, and requires per-language and per-framework support.
Cybersecurity capability evaluations (orthogonal tasks)
- RedCode (Guo et al., 2024) — evaluates generating malicious code to attack others; NYU CTF (Shao et al., 2024) and Cybench (Zhang et al., 2024) — evaluate LLMs generating exploits against software with known vulnerabilities. The authors state that these are orthogonal to the task in this paper.
Baselines and comparison setup: This paper is a benchmark paper and has no method baseline; as a comparison, the authors compared the detection differences between the static analysis tool Snyk Code and BaxBench exploits on correct programs generated by o1 (n=237), and compared the OpenHands agent scaffold (Wang et al., 2024) on Claude-3.5 Sonnet.
The authors position BaxBench as a complement to existing benchmarks: it measures both correctness and security, targets complete backend applications, and uses executable exploits rather than static analysis.
How does the paper address this problem?
BaxBench uses 28 scenarios × 14 frameworks to form 392 tasks, with functional tests determining correctness and executable exploits determining security.
Overall idea: take
What experiments did the paper conduct?
Across 11 LLMs, the highest pass@1 is 62% (o1) and the highest sec_pass@1 is 35% (o3-mini); the authors state that about half of correct programs can be compromised.
Experimental setup
- Models tested (11): OpenAI o1, OpenAI o3-mini, GPT-4o, Claude-3.5 Sonnet, DeepSeek-R1, DeepSeek-V3, Codestral, Qwen2.5 Coder, Llama-3.3 70B, Qwen2.5 72B, Qwen2.5 7B; 6 providers, 4 closed-source, 7 open-source.
- Tasks and sampling: 392 tasks; non-reasoning models were sampled 10 solutions per task at temperature 0.4; reasoning models (o1, o3-mini, DeepSeek-R1) were sampled only 1 solution per task due to cost and time, with DeepSeek-R1 using temperature 0 and o1 and o3-mini having non-adjustable temperature.
- Prompts: The main experiments use OpenAPI specifications; three additional security prompts are set—no security reminder, a generic security reminder (requiring adherence to security best practices), and an oracle security reminder (listing all potential CWEs and descriptions for the scenario, which the authors describe as an unrealistic upper-bound setting).
- Metrics and determination: pass@1 (all functional tests pass) and sec_pass@1 (passes tests and no exploit succeeds); any successful exploit means the program is judged insecure; there is no LLM judge, and determination is programmatic execution.
Main results
According to Figure 3 (392 tasks, no security reminder prompt; pass@1 / sec_pass@1):
Model pass@1 sec_pass@1 OpenAI o3-mini 61% 35% DeepSeek-R1 56% 34% Claude-3.5 Sonnet 56% 31% OpenAI o1 62% 28% GPT-4o 45% 22% DeepSeek-V3 40% 19% Codestral 37% 14% Qwen2.5 Coder 35% 12% Llama-3.3 70B 34% 9% Qwen2.5 72B 25% 9% Qwen2.5 7B 22% 5% - The authors state that about half of the programs that pass functional tests for each model can be compromised by exploits; o1, which has the highest functional correctness, is surpassed on sec_pass@1 by o3-mini, DeepSeek-R1 and Claude-3.5 Sonnet, with o3-mini 6% higher than o1.
- The authors believe that flagship LLMs cannot yet autonomously generate deployable backends.
Security prompts and agents
- Comparison of three prompts (Figure 4, 5 models): The oracle reminder yields the highest sec_pass@1 on all models, but usually lowers pass@1; the authors state that the three reasoning models already show considerable improvement under the generic reminder, while non-reasoning models (GPT-4o etc.) show no obvious improvement.
- OpenHands agent (Table 2, Claude-3.5 Sonnet, 351 tasks, excluding the incompatible Python-Django and Compiler environments): Without a reminder, pass@1 rises from 53.6% to 59.5% and sec_pass@1 changes from 32.9% to 31.8%; under the oracle reminder, sec_pass@1 rises from 35.4% to 39.0% (+7.2%, versus +2.5% for the base model). The authors believe that test-time compute helps security.
Framework, scenario and complexity analysis
- Framework influence (Figure 5, o1, three prompts): The authors state that correctness and security vary with language popularity and framework complexity, being better on Python, Go and JavaScript frameworks and worse on Rust-Actix and PHP-Lumen, and that the proportion of vulnerabilities among correct solutions is higher on these frameworks; multi-file frameworks (marked * in the figure) are harder.
- Scenario complexity (Figure 6): The average pass@1 of each scenario is negatively correlated with the number of OpenAPI specification tokens (OLS fit ρ=-0.49); the authors point out that there are also exceptional scenarios with short specifications but difficult logic.
- Security overhead: Secure solutions relative to
What are some points that can be further explored?
The authors list directions such as extending exploits, frameworks and scenarios, and contamination prevention; the experiments cover 11 models and 392 tasks, and reasoning models are sampled only once.
Limitations and future directions noted by the authors
- Add exploits and test cases: §5 Limitations states that more exploits and test cases can be added to scenarios to tighten the performance upper bound.
- Add frameworks: §5 Limitations states that more frameworks can be added to broaden domain relevance.
- Increase the number, diversity and complexity of scenarios: §5 Limitations states that this can keep the benchmark challenging over the long term; the authors plan to keep expanding it and call for community contributions.
- Benchmark contamination: §5 Limitations states that contamination cannot be fully prevented after public release; the authors state that they do not release golden solutions, that accidental contamination is overall unlikely, and that they plan to maintain representativeness through continuous updates.
Scope of experimental coverage
- A total of 11 models were tested (4 closed-source, 7 open-source), with 28 scenarios × 14 frameworks = 392 tasks (§4).
- Non-reasoning models were sampled 10 times per task (temperature 0.4); reasoning models o1, o3-mini and DeepSeek-R1 were sampled only 1 time per task, so their pass@5/sec_pass@5 are not reported (Appendix D.1).
- The agent experiments cover only Claude-3.5 Sonnet + OpenHands, and after excluding the Python-Django and Compiler environments there are 351 tasks (Table 2).
- Model subset for the safety prompt experiments: Figure 4 shows 5 models (o1, o3-mini, DeepSeek-R1, Claude-3.5 Sonnet, GPT-4o).
- The comparison with static analysis tools covers only the 237 correct programs generated by Snyk Code and only o1; the manual error analysis covers 20 incorrect programs from o1 (§5).
Summarize the main content of the paper
BaxBench uses 392 backend tasks to test correctness and security simultaneously; across 11 LLMs, the highest sec_pass@1 is only 35%.
BaxBench is a backend code generation benchmark that answers