Detecting Data Poisoning in Code Generation LLMs via Black-Box, Vulnerability-Oriented Scanning

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Yan, Shenao, Ahmed, Shimaa, Jin, Shan, Arora, Sunpreet S., Cai, Yiwei, Wang, Yizhen, Hong, Yuan
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866915871166824448
author Yan, Shenao
Ahmed, Shimaa
Jin, Shan
Arora, Sunpreet S.
Cai, Yiwei
Wang, Yizhen
Hong, Yuan
author_facet Yan, Shenao
Ahmed, Shimaa
Jin, Shan
Arora, Sunpreet S.
Cai, Yiwei
Wang, Yizhen
Hong, Yuan
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2603_17174
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Detecting Data Poisoning in Code Generation LLMs via Black-Box, Vulnerability-Oriented Scanning
Yan, Shenao
Ahmed, Shimaa
Jin, Shan
Arora, Sunpreet S.
Cai, Yiwei
Wang, Yizhen
Hong, Yuan
Cryptography and Security
Artificial Intelligence
Software Engineering
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.
title Detecting Data Poisoning in Code Generation LLMs via Black-Box, Vulnerability-Oriented Scanning
topic Cryptography and Security
Artificial Intelligence
Software Engineering
url https://arxiv.org/abs/2603.17174