AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing

Ana Nunez, Nafis Tanveer Islam, Sumit Kumar Jha, Peyman Najafirad
9/16/2024
cs.SEcs.AI

No official code found. Best implementation: SecureAIAutonomyLab/AutoSafeCoder (28 stars, last commit 2024-09-15).

Abstract

Recent advancements in automatic code generation using large language models (LLMs) have brought us closer to fully automated secure software development. However, existing approaches often rely on a single agent for code generation, which struggles to produce secure, vulnerability-free code. Traditional program synthesis with LLMs has primarily focused on functional correctness, often neglecting critical dynamic security implications that happen during runtime. To address these challenges, we propose AutoSafeCoder, a multi-agent framework that leverages LLM-driven agents for code generation, vulnerability analysis, and security enhancement through continuous collaboration. The framework consists of three agents: a Coding Agent responsible for code generation, a Static Analyzer Agent identifying vulnerabilities, and a Fuzzing Agent performing dynamic testing using a mutation-based fuzzing approach to detect runtime errors. Our contribution focuses on ensuring the safety of multi-agent code generation by integrating dynamic and static testing in an iterative process during code generation by LLM that improves security. Experiments using the SecurityEval dataset demonstrate a 13% reduction in code vulnerabilities compared to baseline LLMs, with no compromise in functionality.

View on arXivView PDF

Code Implementations(1)

284PythonSep 15, 20242 years ago

Similar Papers

Cite this paper

@article{nunez2024autosafecoder,
  title  = {AutoSafeCoder: A Multi-Agent Framework for Securing LLM Code Generation through Static Analysis and Fuzz Testing},
  author = {Ana Nunez and Nafis Tanveer Islam and Sumit Kumar Jha and Peyman Najafirad},
  year   = {2024},
  eprint = {2409.10737},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2409.10737v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2409.10737.svg)](https://codeofpaper.com/paper/2409.10737)

Discussion