Large Language Models for Code: Security Hardening and Adversarial Testing
Jingxuan He, Martin Vechev

TL;DR
This paper introduces SVEN, a novel learning-based method to enhance the security of code generated by large language models, enabling controlled generation of secure or unsafe code without altering the models' weights.
Contribution
The paper proposes SVEN, a property-guided approach for security hardening and adversarial testing of LMs, improving security control while maintaining code correctness.
Findings
SVEN significantly increases secure code generation from 59.1% to 92.3%.
SVEN effectively degrades security in adversarial testing to 36.8%.
SVEN preserves the functional correctness of generated code.
Abstract
Large language models (large LMs) are increasingly trained on massive codebases and used to generate code. However, LMs lack awareness of security and are found to frequently produce unsafe code. This work studies the security of LMs along two important axes: (i) security hardening, which aims to enhance LMs' reliability in generating secure code, and (ii) adversarial testing, which seeks to evaluate LMs' security at an adversarial standpoint. We address both of these by formulating a new security task called controlled code generation. The task is parametric and takes as input a binary property to guide the LM to generate secure or unsafe code, while preserving the LM's capability of generating functionally correct code. We propose a novel learning-based approach called SVEN to solve this task. SVEN leverages property-specific continuous vectors to guide program generation towards the…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
MethodsCodeGen
