不同提示语言对LLM生成代码安全性的影响
作者:
作者单位:

作者简介:

通讯作者:

中图分类号:

基金项目:

内蒙古自治区重点研发与成果转化计划(2025YFSH0157); 专创融合“Python语言与数据分析”建设(ZC2024045)


Impact of Different Prompt Languages on Security of Code Generated by LLM
Author:
Affiliation:

Fund Project:

  • 摘要
  • |
  • 图/表
  • |
  • 访问统计
  • |
  • 参考文献
  • |
  • 相似文献
  • |
  • 引证文献
  • |
  • 资源附件
  • |
  • 文章评论
    摘要:

    近年来, 随着软件开发领域代码规模持续扩大、功能需求与系统架构日趋复杂, 自动化工具已成为提升开发效率的核心支撑, 其中生成式大语言模型(large language model, LLM)在软件开发领域得到了广泛应用. 尽管LLM能显著缩短开发周期, 但研究表明, LLM生成的代码常存在安全漏洞, 可能引发系统风险. 已有研究发现LLM的输出结果会受提示语言差异的影响, 然而针对不同提示语言生成代码安全性的研究与评价仍较为匮乏. 本文旨在探究输入英文提示语言与中文提示语言对代码安全性的影响, 并对其进行系统性评估. 通过在LLM中分别使用英文和中文文本指示代码生成, 分析生成代码的安全性差异. 实验结果表明, 当以英文作为提示语言输入时, LLM生成的代码中出现的漏洞和bug数量相对较少; 而以中文作为提示语言输入时, 生成的代码则更容易出现安全漏洞.

    Abstract:

    In recent years, with the continuous expansion of code scale and the increasing complexity of functional requirements and system architectures in the field of software development, automated tools have become a core support for improving development efficiency. Among these tools, generative large language models (LLMs) have been widely applied in software development. Although LLMs can significantly shorten the development cycle, studies have shown that the code they generate often contains security vulnerabilities. These vulnerabilities may pose risks to the system.Existing research has found that the outputs of LLMs are influenced by differences in prompt languages. However, research and evaluation on the security of code generated using different prompt languages remain insufficient. This study aims to explore the impact of English and Chinese input prompt languages on code security and to conduct a systematic evaluation of this impact. Specifically, English and Chinese texts are used to instruct code generation in LLMs, and the differences in the security of the generated code are analyzed.The experimental results indicate that when English is used as the prompt language, the number of vulnerabilities and bugs in the code generated by LLMs is relatively smaller. In contrast, when Chinese is used as the prompt language, the generated code is more prone to security vulnerabilities.

    参考文献
    相似文献
    引证文献
引用本文

郭亚楠,马瑞强,崔旭,杨皓然.不同提示语言对LLM生成代码安全性的影响.计算机系统应用,2026,35(1):255-262

复制
分享
相关视频

文章指标
  • 点击次数:
  • 下载次数:
  • HTML阅读次数:
  • 引用次数:
历史
  • 收稿日期:2025-03-06
  • 最后修改日期:2025-08-22
  • 录用日期:
  • 在线发布日期: 2025-11-26
  • 出版日期:
文章二维码
您是第位访问者
版权所有:中国科学院软件研究所 京ICP备05046678号-3
地址:北京市海淀区中关村南四街4号,邮政编码:100190
电话:010-62661041 传真: Email:csa@iscas.ac.cn
技术支持:北京勤云科技发展有限公司

京公网安备 11040202500063号