Balancing Security and Correctness in Code Generation: An Empirical Study on Commercial Large Language Models

被引:0
|
作者
Black, Gavin S. [1 ]
Rimal, Bhaskar P. [2 ]
Vaidyan, Varghese Mathew [1 ]
机构
[1] Dakota State Univ, Beacom Coll Comp & Cyber Sci, Madison, SD 57042 USA
[2] Univ Idaho, Dept Comp Sci, Moscow, ID 83844 USA
关键词
Codes; Security; Testing; Task analysis; Software; Logic; Computational intelligence; Code generation; code security; CWE; large language models; prompt engineering; vulnerability;
D O I
10.1109/TETCI.2024.3446695
中图分类号
TP18 [人工智能理论];
学科分类号
081104 ; 0812 ; 0835 ; 1405 ;
摘要
Large language models (LLMs) continue to be adopted for a multitude of previously manual tasks, with code generation as a prominent use. Multiple commercial models have seen wide adoption due to the accessible nature of the interface. Simple prompts can lead to working solutions that save developers time. However, the generated code has a significant challenge with maintaining security. There are no guarantees on code safety, and LLM responses can readily include known weaknesses. To address this concern, our research examines different prompt types for shaping responses from code generation tasks to produce safer outputs. The top set of common weaknesses is generated through unconditioned prompts to create vulnerable code across multiple commercial LLMs. These inputs are then paired with different contexts, roles, and identification prompts intended to improve security. Our findings show that the inclusion of appropriate guidance reduces vulnerabilities in generated code, with the choice of model having the most significant effect. Additionally, timings are presented to demonstrate the efficiency of singular requests that limit the number of model interactions.
引用
收藏
页码:419 / 430
页数:12
相关论文
共 50 条
  • [21] Multi-stage guided code generation for Large Language Models
    Han, Yewei
    Lyu, Chen
    ENGINEERING APPLICATIONS OF ARTIFICIAL INTELLIGENCE, 2025, 139
  • [22] Large Language Models and Security
    Bezzi, Michele
    IEEE SECURITY & PRIVACY, 2024, 22 (02) : 60 - 68
  • [23] Security Policy Generation and Verification through Large Language Models: A proposal
    Martinelli, Fabio
    Mercaldo, Francesco
    Petrillo, Luca
    Santone, Antonella
    PROCEEDINGS OF THE FOURTEENTH ACM CONFERENCE ON DATA AND APPLICATION SECURITY AND PRIVACY, CODASPY 2024, 2024, : 143 - 145
  • [24] Optimizing Search-Based Unit Test Generation with Large Language Models: An Empirical Study
    Xiao, Danni
    Guo, Yimeng
    Li, Yanhui
    Chen, Lin
    PROCEEDINGS OF THE 15TH ASIA-PACIFIC SYMPOSIUM ON INTERNETWARE, INTERNETWARE 2024, 2024, : 71 - 80
  • [25] Implementing large language models in healthcare while balancing control, collaboration, costs and security
    Dennstadt, Fabio
    Hastings, Janna
    Putora, Paul Martin
    Schmerder, Max
    Cihoric, Nikola
    NPJ DIGITAL MEDICINE, 2025, 8 (01):
  • [26] Invited Paper: VerilogEval: Evaluating Large Language Models for Verilog Code Generation
    Liu, Mingjie
    Pinckney, Nathaniel
    Khailany, Brucek
    Ren, Haoxing
    2023 IEEE/ACM INTERNATIONAL CONFERENCE ON COMPUTER AIDED DESIGN, ICCAD, 2023,
  • [27] Code-level quantum circuit generation based on large language models
    He, Zhimin
    Li, Guohong
    Situ, Haozhen
    Zhou, Yan
    Zheng, Shenggen
    Li, Lvzhou
    SCIENTIA SINICA-PHYSICA MECHANICA & ASTRONOMICA, 2025, 55 (04)
  • [28] FormalEval: A Method for Automatic Evaluation of Code Generation via Large Language Models
    Yang, Sichao
    Yang, Ye
    2024 INTERNATIONAL SYMPOSIUM OF ELECTRONICS DESIGN AUTOMATION, ISEDA 2024, 2024, : 660 - 665
  • [29] Automatic Generation of Programming Exercises and Code Explanations Using Large Language Models
    Sarsa, Sami
    Denny, Paul
    Hellas, Arto
    Leinonen, Juho
    PROCEEDINGS OF THE 2022 ACM CONFERENCE ON INTERNATIONAL COMPUTING EDUCATION RESEARCH, ICER 2022, VOL. 1, 2023, : 27 - 43
  • [30] Hot or Cold? Adaptive Temperature Sampling for Code Generation with Large Language Models
    Zhu, Yuqi
    Li, Jia
    Li, Ge
    Zhao, YunFei
    Li, Jia
    Jin, Zhi
    Mei, Hong
    THIRTY-EIGHTH AAAI CONFERENCE ON ARTIFICIAL INTELLIGENCE, VOL 38 NO 1, 2024, : 437 - 445