Skip to main content
QUICK REVIEW

[论文解读] Detecting Data Poisoning in Code Generation LLMs via Black-Box, Vulnerability-Oriented Scanning

Shenao Yan, Shimaa Abd Allah Ahmed|arXiv (Cornell University)|Mar 17, 2026
Information and Cyber SecurityComputer Science被引用 0
一句话总结

本论文提出 CodeScan,一种针对代码生成 LLM 的黑盒中毒扫描框架,利用结构发散性与基于 LLM 的漏洞分析来检测并恢复攻击目标,在代码场景中优于 BAIT。

ABSTRACT

Code generation large language models (LLMs) are increasingly integrated into modern software development workflows. Recent work has shown that these models are vulnerable to backdoor and poisoning attacks that induce the generation of insecure code, yet effective defenses remain limited. Existing scanning approaches rely on token-level generation consistency to invert attack targets, which is ineffective for source code where identical semantics can appear in diverse syntactic forms. We present CodeScan, which, to the best of our knowledge, is the first poisoning-scanning framework tailored to code generation models. CodeScan identifies attack targets by analyzing structural similarities across multiple generations conditioned on different clean prompts. It combines iterative divergence analysis with abstract syntax tree (AST)-based normalization to abstract away surface-level variation and unify semantically equivalent code, isolating structures that recur consistently across generations. CodeScan then applies LLM-based vulnerability analysis to determine whether the extracted structures contain security vulnerabilities and flags the model as compromised when such a structure is found. We evaluate CodeScan against four representative attacks under both backdoor and poisoning settings across three real-world vulnerability classes. Experiments on 108 models spanning three architectures and multiple model sizes demonstrate 97%+ detection accuracy with substantially lower false positives than prior methods.

研究动机与目标

  • Identify vulnerabilities in code generation LLMs caused by data poisoning and backdoors.
  • Develop a defense that works in a black-box setting without access to training data or model internals.
  • Overcome token-level divergence limitations by focusing on structural code patterns and semantic vulnerabilities.
  • Evaluate effectiveness across multiple architectures, model sizes, and vulnerability classes.

提出的方法

  • Traverse the model vocabulary with clean prompts to collect generations for each candidate token.
  • Convert generated code to AST-based representations and cluster by structural similarity to identify low-divergence patterns.
  • Apply a vulnerability detector (LLM-based) to assess whether structurally consistent patterns contain the targeted vulnerability.
  • Extract recovered attack targets from dominant structural clusters via AST-based majority voting on function calls and arguments.
  • Use a vulnerability detector (GPT-5-mini) to decide if a biased trace contains the specified vulnerability.
  • Compare CodeScan to BAIT using F1-score, precision, recall, BLEU, AST distance, and scanning overhead.

实验结果

研究问题

  • RQ1Can a black-box, vulnerability-oriented scanning approach reliably detect data poisoning in code generation LLMs?
  • RQ2Do structurally consistent code patterns across generations reveal attack targets better than token-level methods in code settings?
  • RQ3Can LLM-based vulnerability analysis robustly identify transformed or obfuscated attack targets?
  • RQ4How does CodeScan perform across architectures, sizes, and vulnerability classes compared to BAIT?

主要发现

  • CodeScan achieves 97%+ detection accuracy with substantially lower false positives than prior methods.
  • CodeScan outperforms BAIT, which achieves an average F1-score of 0.17 in their evaluations.
  • Evaluation spans 108 models across three architectures and multiple sizes, including large models like CodeLlama-34B.
  • CodeScan uses structural divergence plus vulnerability analysis to recover attack targets.
  • Vulnerability analysis via GPT-5-mini effectively detects transformed or obfuscated targets.
  • CodeScan demonstrates robustness to transformed code and provides practical, scalable scanning.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。