CodeScan detects poisoning in code-generation LLMs with >97% accuracy
CodeScan can identify compromised code-generation models with over 97% detection accuracy and low false positives
AI/ML arXiv 17 Mar 2026 Method Prototype evidence
Published as “Detecting Data Poisoning in Code Generation LLMs via Black-Box, Vulnerability-Oriented Scanning”
Why it matters
CodeScan makes large-scale, black-box auditing of code-generation LLMs practical, enabling defenders to spot poisoned models before deployment.
Summary
CodeScan detects data-poisoning in code-generation LLMs with near-perfect accuracy, achieving 100% recall and 0%-16.7% false-positive rates across 108 models, far outperforming the prior BAIT scanner. It does this by looking for recurring AST-normalized code structures rather than token-level consistency, then using an LLM-based vulnerability analyzer to flag malicious patterns. The evidence comes from extensive experiments on three architectures, multiple model sizes, and four attack strategies, showing an order-of-magnitude speedup and far fewer false alarms. However, the paper reports some missed detections and a 16.7% false-positive rate for two vulnerability classes, and a few failure cases on specific attacks.
What they found 3
- CodeScan attains perfect recall on all attacked models across three CWE vulnerabilities.
“CodeScan consistently achieves perfect detection performance. Across all three vulnerabilities (V1-V3) and all evaluated models, CodeScan attains 100% recall, correctly identifying every attacked model.”
- Scanning overhead is reduced by up to an order of magnitude compared to BAIT.
“CodeScan reduces scanning overhead by up to an order of magnitude compared to BAIT. For example, under V1, the average scanning overhead of BAIT exceeds 12,594 seconds, whereas CodeScan requires only 1,681 seconds on average.”
- False-positive rates are dramatically lower: 0% for V1 and 16.67% for V2/V3, versus 100% for BAIT on V1/V2.
“CodeScan achieves an FPR of 0% under V1, and limits the FPR to 16.67% under both V2 and V3. In contrast, BAIT produces substantially higher false positives. In particular, BAIT yields an FPR of 100% for both V1 and V2, incorrectly classifying all clean models as attacked, and still incurs a non-negligible FPR of 16.67% under V3.”
Caveats 4
- In backdoor attack settings, CodeScan precision is 0.0000 for some models while recall is 1.0000, indicating many false positives or missed true detections (Table 2).
- Two wrong inversions were observed for the V1 vulnerability, specifically on the TROJANPUZZLE backdoor attack against QwenCoder and StarCoder.
- We observe a small number of failure cases for CodeScan, including three cases when scanning attacked models and two cases when scanning clean models.
- the performance of CodeScan closely depend on the reliability of the vulnerability analyzer.
What’s new here 4
- Scans code-generation LLMs using structural (AST) similarity instead of token-level consistency.
- Integrates an LLM-based vulnerability analyzer to directly assess security of extracted code structures.
- Achieves dramatically lower false-positive rates and faster scanning than the BAIT baseline.
- Demonstrates scalability to large models (up to 34B parameters) with consistent detection performance.