paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Coverage-Based Harmfulness Testing for LLM Code Transformation

面向 LLM 代码转换的基于覆盖率的有害性测试
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 2/10 · 该论文关注 Code LLM 代码转换中的有害内容测试与内容审核漏洞,属于 LLM 安全/测试方向,未涉及用户核心关注的静态分析、Agentic 程序分析、LLM 辅助静态分析/形式化验证、浮点程序分析或贝叶斯程序分析。引用 0 inbox
Honghao Tan, Haibo Wang, Diany Pressato, Yisen Xu, Shin Hwei Tan
crossref: 2026-09-12

AI 速览

一句话:提出基于覆盖率的 CHT 框架,自动合成有害提示测试 Code LLM 代码转换中的内容审核漏洞,并提出两阶段防护。

代码大模型在语义保持的代码转换中可能被诱导生成有害内容(如标识符或注释中的有害关键词),危害开发者。作者先归纳出 32 种可注入有害内容的程序转换,提出基于覆盖率的危害性测试框架 CHT:用注入有害关键词的提示模板自动合成提示,对挖掘的良性程序执行多种转换,并对生成的自然语言解释与修改代码做输出损害度量,而非仅检测审核是否被绕过。在四个 Code LLM 与 gpt-4o-mini 上评估发现,65.93% 案例可无警告生成有害关键词,并暴露审核缺陷、任务执行不足与审核宽松等问题。并提出生成前检查提示的两阶段方法,将内容审核提升 483.76%。

问题
研究 Code LLM 在语义保持的代码转换中可能引入有害内容的问题,以及现有内容审核在代码任务中的脆弱性。
方法
提出 CHT,基于注入有害关键词的提示模板自动合成提示,对挖掘的良性程序执行多种转换,并通过输出损害度量评估生成的自然语言解释和修改后代码。
评估
在四个 Code LLM 和 gpt-4o-mini 上评估,发现 65.93% 的案例可绕过审核且无警告,并验证两阶段预检查方法将内容审核提升 483.76%。
原文摘要(Abstract)

Harmful content embedded in program elements within source code may have detrimental impact on mental health of software developers, and promote harmful behavior. Our key insight is that software developers may introduce harmful content into source code via diverse semantic-preserving program transformations when using Code Large Language Models (Code LLMs). To analyze the space of program transformations that may be used to introduce harmful content into auto-generated code, we conduct a preliminary study that revealed 32 different types of transformations that can be used to introduce harmful content in source code. Based on our study, we propose CHT, a novel coverage-based harmfulness testing framework that automatically synthesizes prompts using a set of prompt templates injected with diverse harmful keywords to perform various types of transformations on a set of mined benign programs. Instead of checking if the content moderation has been bypassed as prior testing approaches, CHT performs output damage measurement to assess potential harm that can be incurred by the generated outputs (i.e., natural language explanation and modified code). By considering output damage, CHT revealed several problems in Code LLMs: (1) bugs in content moderation for code (Code LLMs produce the harmful code without providing any warning), (2) inadequacy in performing code-related task (e.g., Code LLMs may resort to explaining the given code instead of performing the instructed transformation task), and (3) lenient content moderation (gives warning but the modified code with harmful content is still produced). Our evaluations of CHT on four Code LLMs and gpt-4o-mini (general LLM) show that content moderation in Code LLMs is relatively easy to bypass where LLMs may generate harmful keywords embedded within identifier names or code comments without giving any warning (65.93% in our evaluation). To improve the robustness of content moderation in code-related tasks, we propose a two-phase approach that checks if the prompt contains any harmful content before generating any output. Our evaluation shows that our proposed approach improves the content moderation of Code LLM by 483.76%.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9246,
  title = {Coverage-Based Harmfulness Testing for LLM Code Transformation},
  author = {Honghao Tan and Haibo Wang and Diany Pressato and Yisen Xu and Shin Hwei Tan},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00086}
}