Saved in:
Bibliographic Details
Main Authors: Tsai, Chi-Chien, Yu, Chia-Mu, Lin, Ying-Dar, Wu, Yu-Sung, Lee, Wei-Bin
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2502.20246
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866916634887716864
author Tsai, Chi-Chien
Yu, Chia-Mu
Lin, Ying-Dar
Wu, Yu-Sung
Lee, Wei-Bin
author_facet Tsai, Chi-Chien
Yu, Chia-Mu
Lin, Ying-Dar
Wu, Yu-Sung
Lee, Wei-Bin
contents The increasing adoption of large language models (LLMs) for code-related tasks has raised concerns about the security of their training datasets. One critical threat is dead code poisoning, where syntactically valid but functionally redundant code is injected into training data to manipulate model behavior. Such attacks can degrade the performance of neural code search systems, leading to biased or insecure code suggestions. Existing detection methods, such as token-level perplexity analysis, fail to effectively identify dead code due to the structural and contextual characteristics of programming languages. In this paper, we propose DePA (Dead Code Perplexity Analysis), a novel line-level detection and cleansing method tailored to the structural properties of code. DePA computes line-level perplexity by leveraging the contextual relationships between code lines and identifies anomalous lines by comparing their perplexity to the overall distribution within the file. Our experiments on benchmark datasets demonstrate that DePA significantly outperforms existing methods, achieving 0.14-0.19 improvement in detection F1-score and a 44-65% increase in poisoned segment localization precision. Furthermore, DePA enhances detection speed by 0.62-23x, making it practical for large-scale dataset cleansing. Overall, by addressing the unique challenges of dead code poisoning, DePA provides a robust and efficient solution for safeguarding the integrity of code generation model training datasets.
format Preprint
id arxiv_https___arxiv_org_abs_2502_20246
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Beyond Natural Language Perplexity: Detecting Dead Code Poisoning in Code Generation Datasets
Tsai, Chi-Chien
Yu, Chia-Mu
Lin, Ying-Dar
Wu, Yu-Sung
Lee, Wei-Bin
Computation and Language
The increasing adoption of large language models (LLMs) for code-related tasks has raised concerns about the security of their training datasets. One critical threat is dead code poisoning, where syntactically valid but functionally redundant code is injected into training data to manipulate model behavior. Such attacks can degrade the performance of neural code search systems, leading to biased or insecure code suggestions. Existing detection methods, such as token-level perplexity analysis, fail to effectively identify dead code due to the structural and contextual characteristics of programming languages. In this paper, we propose DePA (Dead Code Perplexity Analysis), a novel line-level detection and cleansing method tailored to the structural properties of code. DePA computes line-level perplexity by leveraging the contextual relationships between code lines and identifies anomalous lines by comparing their perplexity to the overall distribution within the file. Our experiments on benchmark datasets demonstrate that DePA significantly outperforms existing methods, achieving 0.14-0.19 improvement in detection F1-score and a 44-65% increase in poisoned segment localization precision. Furthermore, DePA enhances detection speed by 0.62-23x, making it practical for large-scale dataset cleansing. Overall, by addressing the unique challenges of dead code poisoning, DePA provides a robust and efficient solution for safeguarding the integrity of code generation model training datasets.
title Beyond Natural Language Perplexity: Detecting Dead Code Poisoning in Code Generation Datasets
topic Computation and Language
url https://arxiv.org/abs/2502.20246