How do large language models perform as end-to-end secure code agents for Python?How Well Do Large Language Models Serve as End-to-End Secure Code Agents for Python?
The study evaluated the ability of GPT-3.5 and GPT-4 to identify and fix vulnerabilities in Python code generated by four LLMs, and tested an iterative repair tool. The study states that more than 75% of the code generated by the models on the SecurityEval benchmark contained vulnerabilities, and holds that they lack awareness of scenario-relevant security risks. GPT-3.5 and GPT-4 could not accurately identify vulnerabilities in their own generated code; when fixing insecure code generated by the four LLMs, the success rate was 33.2%–59.6%, but performance was poorer when fixing their own code, indicating a self-repair blind spot. To address the limitations of single-round repair, the authors developed a lightweight tool that prompts the LLM through iterative repair to generate safer source code; with a semantic analysis engine, the repair success rate rose to 65.9%–85.5%.