Large Language Models for Code: Security Hardening and Adversarial Testing
AI-generated Key Points
- Large language models (LMs) lack security awareness and often produce unsafe code
- Authors focus on studying LM security in two aspects: security hardening and adversarial testing
- Proposed a new security task called controlled code generation
- Introduced a learning-based approach called SVEN to solve the task
- SVEN uses property-specific continuous vectors to guide program generation towards desired properties without modifying LM weights
- Training procedure optimizes continuous vectors using specialized loss terms on different regions of code with high-quality dataset
- Evaluation shows SVEN is highly effective in achieving strong security control
- SVEN increases generation of secure code from 59.1% to 92.3% during security hardening and decreases it to 36.8% during adversarial testing for a CodeGen LM with 2.7B parameters
- SVEN maintains functional correctness similar to original LMs
- This work addresses security concerns of large LMs used for generating code by introducing controlled code generation task and proposing SVEN as an effective approach
Authors: Jingxuan He, Martin Vechev
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 given property, without modifying the LM's weights. Our training procedure optimizes these continuous vectors by enforcing specialized loss terms on different regions of code, using a high-quality dataset carefully curated by us. Our extensive evaluation shows that SVEN is highly effective in achieving strong security control. For instance, a state-of-the-art CodeGen LM with 2.7B parameters generates secure code for 59.1% of the time. When we employ SVEN to perform security hardening (or adversarial testing) on this LM, the ratio is significantly boosted to 92.3% (or degraded to 36.8%). Importantly, SVEN closely matches the original LMs in functional correctness.
Ask questions about this paper to our AI assistant
You can also chat with multiple papers at once here.
Assess the quality of the AI-generated content by voting
Score: 0
Why do we need votes?
Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.
The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.
Similar papers summarized with our AI tools
Navigate through even more similar papers through a
tree representationLook for similar papers (in beta version)
By clicking on the button above, our algorithm will scan all papers in our database to find the closest based on the contents of the full papers and not just on metadata. Please note that it only works for papers that we have generated summaries for and you can rerun it from time to time to get a more accurate result while our database grows.
Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.