Applying Security by Design at the Point of Execution: How Governed Security Requirements Affect the Security of AI-Generated Code
Abstract
Security by design asks that security requirements are defined before code is written. Secure-code benchmarks typically measure the opposite situation: the agent receives the task without requirements and is scored with security tests it has not seen. We measured what changes when security requirements, selected from a governed security-by-design knowledge base (SbD-ToE) and delivered through a Model Context Protocol (MCP) server, are given to the generator at the point of execution. On DualGauge, which scores with a language-model judge, we ran 59 Python tasks: the share of tasks passing all security tests rose from 44.1% to 78.0% and the share of security tests passed from 77.4% to 93.0%. On BaxBench, which runs functional tests and real exploits in containers, we ran 28 backend scenarios: among functionally correct solutions, the share with no successful exploit rose from 65% to 86%, comparable to the authors' Oracle Security Reminder (85%), which they call an unrealistic upper bound; the requirement delivery reached it without knowing the tests. The study has limits. The pre-specified joint secure-and-functional metric did not improve significantly on either benchmark. The code written with the governed requirements is stricter, and it failed functional tests that fix values the task never states; we attribute those failures case by case in a post-hoc analysis. Each experiment used one model and one generation per task. The requirements come from the author's open-source manual; we do not assess its completeness. Governed security requirements delivered at the point of execution appear to improve the security of generated code. Current benchmarks cannot tell whether that code meets the security requirements that apply to it, only whether it shows the weaknesses their evaluators were built to detect. We propose measuring conformance with the applicable requirements.
Create a lesson
Metadata
- Categories
- cs.SE, cs.CR
- Comments
- 17 pages, 3 figures, 4 tables, 7 appendices. Artefact: doi:10.5281/zenodo.23213449 and doi:10.6084/m9.figshare.34168182
Related papers
RBioBench: an execution-based benchmark for biomedical R code generation
Shared title terminologycs.SEXihao Piao, Dong Wang, Ziwei Yang et al.
AI-Generated Code Issues: A Taxonomy from Repository Histories, AI Conversations, and Developer Interviews
Shared title terminologycs.SERosalia Tufano, Nargiz Humbatova, Daniele Bifolco et al.
Validating Multi-Model AI-Generated Acceptance Criteria in Requirements Engineering
Shared title terminologycs.SEMateen Ahmed Abbasi, Petri Ihantola, Tommi Mikkonen et al.
Executable but Unfaithful: Mock Object, Stub, and Assertion Generation by LLMs and Coding Agents
Shared title terminologycs.SEHao Ning, Jiahui Dong, Zhen Yang et al.
SCCGBench: Executability-Oriented Evaluation for Real-World Web Service-Call Code Generation
Shared title terminologycs.SEShuo Wang, Guodong Fan, Ming Zhu et al.
Newer and Bigger, but Safer? A Longitudinal Study of the Functionality-Security Gap in LLM-Generated Code
Shared title terminologycs.SEThiago Santos de Moura, Fynn Matuschek, Flavio Toffalini et al.