Skip to main content
QUICK REVIEW

[Paper 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 Science0 citations
TL;DR

The paper presents CodeScan, a black-box poisoning-scanning framework for code generation LLMs that uses structural divergence and LLM-based vulnerability analysis to detect and recover attack targets, outperforming BAIT in code settings.

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.

Motivation & Objective

  • 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.

Proposed method

  • 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.

Experimental results

Research questions

  • 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?

Key findings

  • 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.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.