CoChat

Large Language Models for Code: Security Hardening and Adversarial Testing

Open access
He, Jingxuan, Vechev, Martin · 2023 · Proceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Security
Cited by 138

The DOI matches its Crossref record; 36 of the 36 references it cites were found in a registry or an index.

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.

Overview

The claims and statistics of this paper haven’t been checked yet.

Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.

A few free checks a day · papers already verified open instantly · results are public

Integrity signals

Registry

Crossref · 10.1145/3576915.3623175

Cites

36 of 36 references verified0 citation errors · 0 not checkable

Statistics

Verification

Claims the paper makes

The claims and statistics of this paper haven’t been checked yet.

Free: it reads the open-access text and checks the first 5 claims that cite a source we can check. Create a free account to check every claim.

A few free checks a day · papers already verified open instantly · results are public

Self-check

Percentages, sums and reported differences re-computed from the paper’s own numbers.

The self-check needs the paper’s full text.

Citations

Cites

Show all 36 references

Research works printed but not linked: 28

  1. 10.1109/SP46214.2022.9833659 · DOI
  2. Guru Prasad Bhandari Amara Naseer and Leon Moonen. 2021. CVEfixes: Automated Collection of Vulnerabilities and Their Fixes from Open-source Software. In PROMISE. https://doi.org/10.1145/3475960.3475985 · DOI · Paper page
  3. 10.1109/TSE.2021.3087402 · DOI · Paper page
  4. 10.1109/TSE.2022.3147265 · DOI · Paper page
  5. 10.1109/ICSE48619.2023.00022 · DOI · Paper page
  6. 10.18653/v1/n19--1423 · doi:10.18653/v1/n19--1423
  7. 10.1109/SP.2016.15 · DOI · Paper page
  8. 10.1145/3379597.3387501 · DOI · Paper page
  9. Luca Gazzola Daniela Micucci and Leonardo Mariani. 2018. Automatic Software Repair: a Survey. In ICSE. https://doi.org/10.1145/3180155.3182526 · DOI · Paper page
  10. 10.1109/MS.2021.3072577 · DOI
  11. Jingxuan He Luca Beurer-Kellner and Martin Vechev. 2022. On Distribution Shift in Learning-based Bug Detectors. In ICML. https://proceedings.mlr.press/v162/he22a.html
  12. 10.1162/coli_a_00426 · DOI · Paper page
  13. Tomasz Korbak Hady Elsahar Germán Kruszewski and Marc Dymetman. 2022. Controlling Conditional Language Models without Catastrophic Forgetting. In ICML Kamalika Chaudhuri Stefanie Jegelka Le Song Csaba Szepesvári Gang Niu and Sivan Sabato (Eds.). https://proceedings.mlr.press/v162/korbak22a.html
  14. Hung Le, Yue Wang, Akhilesh Deepak Gotmare, Silvio Savarese, and Steven Chu-Hong Hoi. 2022. CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learning. In NeurIPS. http://papers.nips.cc/paper_files/paper/2022/hash/8636419dea1aa9fbd25fc4248e702da4-Abstract-Conference.html
  15. 10.1109/TDSC.2021.3051525 · DOI · Paper page
  16. Zhen Li, Deqing Zou, Shouhuai Xu, Xinyu Ou, Hai Jin, Sujuan Wang, Zhijun Deng, and Yuyi Zhong. 2018. VulDeePecker: A Deep Learning-Based System for Vulnerability Detection. In NDSS. http://wp.internetsociety.org/ndss/wp-content/uploads/sites/25/2018/02/ndss2018_03A-2_Li_paper.pdf
  17. 10.1109/JPROC.2020.2993293 · DOI · Paper page
  18. Georgios Nikitopoulos Konstantina Dritsa Panos Louridas and Dimitris Mitropoulos. 2021. CrossVul: a Cross-language Vulnerability Dataset with Commit Data. In ESEC/FSE. https://doi.org/10.1145/3468264.3473122 · DOI
  19. Yu Nong Yuzhe Ou Michael Pradel Feng Chen and Haipeng Cai. 2022. Generating Realistic Vulnerabilities via Neural Code Editing: an Empirical Study. In ESEC/FSE. https://doi.org/10.1145/3540250.3549128 · DOI
  20. Hammond Pearce, Benjamin Tan, Baleegh Ahmad, Ramesh Karri, and Brendan Dolan-Gavitt. 2023. Examining Zero-Shot Vulnerability Repair with Large Language Models. In IEEE S&P. https://doi.ieeecomputersociety.org/10.1109/SP46215.2023.00001 · doi:10.1109/sp46215.2023.00001
  21. Sofia Reis and Rui Abreu. 2021. A Ground-truth Dataset of Real Security Patches. CoRR, Vol. abs/2110.09635 (2021). https://arxiv.org/abs/2110.09635 · arXiv
  22. Roei Schuster Congzheng Song Eran Tromer and Vitaly Shmatikov. 2021. You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completion. In USENIX Security. https://www.usenix.org/conference/usenixsecurity21/presentation/schuster
  23. Justin Smith Brittany Johnson Emerson R. Murphy-Hill Bill Chu and Heather Richter Lipford. 2015. Questions Developers Ask While Diagnosing Potential Security Vulnerabilities with Static Analysis. In ESEC/FSE. https://doi.org/10.1145/2786805.2786812 · DOI
  24. Zhensu Sun Xiaoning Du Fu Song Mingze Ni and Li Li. 2022. CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning. In WWW. https://doi.org/10.1145/3485447.3512225 · DOI · Paper page
  25. Ashish Vaswani Noam Shazeer Niki Parmar Jakob Uszkoreit Llion Jones Aidan N. Gomez Lukasz Kaiser and Illia Polosukhin. 2017. Attention is All you Need. In NeurIPS. https://proceedings.neurips.cc/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html
  26. 10.1016/j.infsof.2021.106809 · DOI · Paper page
  27. Zenong Zhang, Zach Patterson, Michael Hicks, and Shiyi Wei. 2022. FIXREVERTER: A Realistic Bug Injection Methodology for Benchmarking Fuzz Testing. In USENIX Security. https://www.usenix.org/conference/usenixsecurity22/presentation/zhang-zenong
  28. Yaqin Zhou, Shangqing Liu, Jing Kai Siow, Xiaoning Du, and Yang Liu. 2019. Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networks. In NeurIPS. https://proceedings.neurips.cc/paper/2019/hash/49265d2447bc3bbfe9e76306ce40a31f-Abstract.html

Cited by

Metadata

Authors
He, J., & Vechev, M.
Venue
Proceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Security
Publisher
ACM
Published
2023-11-15
Pages
1865-1879
OpenAlex
W4320560161
Cited by
138
References
36
FWCI
26.09
Type
conference paper
Language
en
Open access
hybrid

About these checks

Registry, retraction, Cites and statistics results are computed, not judged, with one exception: a printed reference that no index lists is read once by a model before it counts as a citation error. Claims are extracted by a model and kept only when their quote appears verbatim in the text; each cited source is then checked, with a model’s help, for whether it says what the claim relies on. Those verdicts can be wrong — read the claim’s quote and the cited source before relying on one.

Statistics and arithmetic are recomputed, not judged.

Confidence bands are shown only for fields calibrated on our annotated test set. None is calibrated yet, so no band is shown.

What counts as a claim ›How we measure confidence ›How we check this ›

Are you an author, or do you see a problem with this page? Request a review

Data sources

Bibliographic data: Semantic Scholar, OpenAlex, Crossref.

Contains information from the Semantic Scholar Academic Graph Datasets, made available under the ODC Attribution License (ODC-BY 1.0).

Semantic Scholar’s data is described in: Kinney, R., et al. (2023). The Semantic Scholar Open Data Platform. arXiv:2301.10140.