Investigating How Prompt Language Choice Affects the Security of ChatGPT-Generated Code

Read full text
Authors: Yanan Guo, Ruiqiang Ma, Xu Cui, Haoran Yang, Jerry Yongsheng Jiang
Cited by: 0

Abstract

With the widespread application of generative large language models (such as ChatGPT) in code generation, the security of their output code has attracted increasing attention. However, the impact of suggest language on the security of generated code has not been fully studied. This paper compares and analyses the Python and Java codes generated by ChatGPT under English and Chinese prompts, and systematically evaluates its security differences. Experiments show that the code vulnerabilities generated by English prompts are significantly less than those generated by Chinese prompts, indicating that the choice of prompt language has an important impact on code security. This finding provides practical guidance for developers to optimize prompt engineering, and it is recommended to give priority to the use of English prompts in scenarios with high security requirements.

Fields of Study & Subjects

Software Engineering Research Adversarial Robustness in Machine Learning Web Application Security Vulnerabilities

Publication details

Journal / source
Frontiers in artificial intelligence and applications
Publication date
4 February 2026
Language
EN
Document type
Book chapter