mlsanityData to 14 Oct 2026

Large Language Models for Code: Security Hardening and Adversarial Testing

arXiv 2302.05319 ↗First posted 10 Feb 2023cs.CR cs.LG cs.PLcited by 155

Not on the map. Why?

Cited by 27 in LLM agents and tool use, but placed by its own abstract, which didn’t fit.

Abstract (arXiv)

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.

Key facts. Cited by 155 papers in the map (data through 14 Oct 2026). Builds on 43 of its 76 references that are in the map. First posted on arXiv 10 Feb 2023.

Builds on

43 of 76 references.

References · 43

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2020Language Models are Few-Shot Learnerscited by 32,419
  4. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  5. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,326
  6. 2021Prefix-Tuning: Optimizing Continuous Prompts for Generationcited by 3,915
  7. 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,795
  8. 2021Program Synthesis with Large Language Modelscited by 3,637
  9. 2022Competition-Level Code Generation with AlphaCodecited by 1,462
  10. 2020WILDS: A Benchmark of in-the-Wild Distribution Shiftscited by 1,375
  11. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  12. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
31 more
  1. 2019Plug and Play Language Models: A Simple Approach to Controlled Text Generationcited by 799
  2. 2019CTRL: A Conditional Transformer Language Model for Controllable Generationcited by 762
  3. 2021GPT Understands, Toocited by 716
  4. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
  5. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
  6. 2020GeDi: Generative Discriminator Guided Sequence Generationcited by 378
  7. 2021Learning How to Ask: Querying LMs with Mixtures of Soft Promptscited by 377
  8. 2022A Systematic Evaluation of Large Language Models of Codecited by 363
  9. 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 358
  10. 2019Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networkscited by 272
  11. 2022Efficient Training of Language Models to Fill in the Middlecited by 255
  12. 2021WARP: Word-level Adversarial ReProgrammingcited by 221
  13. 2023SantaCoder: don't reach for the stars!cited by 170
  14. 2020Deep Learning for Text Style Transfer: A Surveycited by 162
  15. 2020Deep Learning based Vulnerability Detection: Are We There Yet?cited by 144
  16. 2022MultiPL-E: A Scalable and Extensible Approach to Benchmarking Neural Code Generationcited by 136
  17. 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 131
  18. 2021Examining Zero-Shot Vulnerability Repair with Large Language Modelscited by 105
  19. 2018SySeVR: A Framework for Using Deep Learning to Detect Software Vulnerabilitiescited by 92
  20. 2021CVEfixes: Automated Collection of Vulnerabilities and Their Fixes from Open-Source Softwarecited by 91
  21. 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 91
  22. 2022Controllable Natural Language Generation with Contrastive Prefixescited by 75
  23. 2018The Art, Science, and Engineering of Fuzzing: A Surveycited by 62
  24. 2020Transcending Transcend: Revisiting Malware Classification in the Presence of Concept Driftcited by 53
  25. 2023Data Quality for Software Vulnerability Datasetscited by 51
  26. 2021CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoningcited by 47
  27. 2021Neural Transfer Learning for Repairing Security Vulnerabilities in C Codecited by 36
  28. 2021Controlling Conditional Language Models without Catastrophic Forgettingcited by 32
  29. 2022VUDENC: Vulnerability Detection with Deep Learning on a Natural Codebase for Pythoncited by 17
  30. 2022On Distribution Shift in Learning-based Bug Detectorscited by 15
  31. 2021A ground-truth dataset of real security patchescited by 2

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2023: 9; 2024: 38; 2025: 60; 2026: 48.

155 papers.

Sort:

By area:

  1. 2023A Survey on Large Language Model (LLM) Security and Privacy: The Good, the Bad, and the Uglycited by 387
  2. 2023Who Wrote this Code? Watermarking for Code Generationcited by 141
  3. 2024Vulnerability Detection with Code Language Models: How Far Are We?cited by 139
  4. 2023Identifying and Mitigating the Security Risks of Generative AIcited by 91
  5. 2024When LLMs Meet Cybersecurity: A Systematic Literature Reviewcited by 71
  6. 2024Instruction Tuning for Secure Code Generationcited by 68
  7. 2024Exploiting LLM Quantizationcited by 65
  8. 2024SelfDefend: LLMs Can Defend Themselves against Jailbreaking in a Practical Mannercited by 63
  9. 2025CWEval: Outcome-driven Evaluation on Functionality and Security of LLM Code Generationcited by 59
  10. 2025LLMs in Software Security: A Survey of Vulnerability Detection Techniques and Insightscited by 47
  11. 2026SWE-chat: Coding Agent Interactions From Real Users in the Wildcited by 43
  12. 2024CYCLE: Learning to Self-Refine the Code Generationcited by 42
38 more
  1. 2025BaxBench: Can LLMs Generate Correct and Secure Backends?cited by 41
  2. 2024Constrained Decoding for Secure Code Generationcited by 37
  3. 2025LessLeak-Bench: A First Investigation of Data Leakage in LLMs Across 83 Software Engineering Benchmarkscited by 37
  4. 2024Large Language Models in Cybersecurity: State-of-the-Artcited by 34
  5. 2024Prompting Techniques for Secure Code Generation: A Systematic Investigationcited by 34
  6. 2023DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructionscited by 33
  7. 2023Natural Language Generation and Understanding of Big Code for AI-Assisted Programming: A Reviewcited by 32
  8. 2023Beyond Accuracy: Evaluating Self-Consistency of Code Large Language Models with IdentityChaincited by 31
  9. 2024Compromising Embodied Agents with Contextual Backdoor Attackscited by 31
  10. 2024Toward Secure Code Generation: Bridging Correctness and Security via Task-Adaptive Vulnerability Modeling and Execution-Based Benchmarkingcited by 27
  11. 2024NoFunEval: Funny How Code LMs Falter on Requirements Beyond Functional Correctnesscited by 26
  12. 2025Exploring the Roles of Large Language Models in Reshaping Transportation Systems: A Survey, Framework, and Roadmapcited by 26
  13. 2024ProSec: Fortifying Code LLMs with Proactive Security Alignmentcited by 25
  14. 2024PerfCodeGen: Improving Performance of LLM Generated Code with Execution Feedbackcited by 24
  15. 2025Frontier AI's Impact on the Cybersecurity Landscapecited by 21
  16. 2024PromSec: Prompt Optimization for Secure Generation of Functional Source Code with Large Language Models (LLMs)cited by 19
  17. 2024Evaluating Software Development Agents: Patch Patterns, Code Quality, and Issue Complexity in Real-World GitHub Scenarioscited by 18
  18. 2025PurpCode: Reasoning for Safer Code Generationcited by 18
  19. 2025From CVE Entries to Verifiable Exploits: An Automated Multi-Agent Framework for Reproducing CVEscited by 18
  20. 2025Correctness Assessment of Code Generated by Large Language Models Using Internal Representationscited by 17
  21. 2024HexaCoder: Secure Code Generation via Oracle-Guided Synthetic Training Datacited by 16
  22. 2025UniGuardian: A Unified Defense for Detecting Prompt Injection, Backdoor Attacks and Adversarial Attacks in Large Language Modelscited by 16
  23. 2025Give LLMs a Security Course: Securing Retrieval-Augmented Code Generation via Knowledge Injectioncited by 16
  24. 2023FRANC: A Lightweight Framework for High-Quality Code Generationcited by 14
  25. 2024Black-Box Adversarial Attacks on LLM-Based Code Completioncited by 14
  26. 2025SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositoriescited by 14
  27. 2025A.S.E: A Repository-Level Benchmark for Evaluating Security in AI-Generated Codecited by 14
  28. 2023Nova: Generative Language Models for Assembly Code with Hierarchical Attention and Contrastive Learningcited by 12
  29. 2025Training Language Models to Generate Quality Code with Program Analysis Feedbackcited by 12
  30. 2025FaultLine: Automated Proof-of-Vulnerability Generation Using LLM Agentscited by 12
  31. 2024Uncovering LLM-Generated Code: A Zero-Shot Synthetic Code Detector via Code Rewritingcited by 11
  32. 2025VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detectioncited by 11
  33. 2024LLMs Can Defend Themselves Against Jailbreaking in a Practical Manner: A Vision Papercited by 10
  34. 2024From Vulnerabilities to Remediation: A Systematic Literature Review of LLMs in Code Securitycited by 10
  35. 2025Rethinking the Evaluation of Secure Code Generationcited by 10
  36. 2025Teaching an Old LLM Secure Coding: Localized Preference Optimization on Distilled Preferencescited by 10
  37. 2025RedCoder: Automated Multi-Turn Red Teaming for Code LLMscited by 9
  38. 2025RedCodeAgent: Automatic Red-teaming Agent against Diverse Code Agentscited by 9

50 most cited of 155 All 155 (JSON)