mlsanityData to 14 Oct 2026

MT4DP: Data Poisoning Attack Detection for DL-based Code Search Models via Metamorphic Testing

arXiv 2507.11092 ↗First posted 15 Jul 2025cs.SEcited by 0

On the map: LLM safety and security → Backdoor and data poisoning attacks

Abstract (arXiv)

Recently, several studies have indicated that data poisoning attacks pose a severe security threat to deep learning-based (DL-based) code search models. Attackers inject carefully crafted malicious patterns into the training data, misleading the code search model to learn these patterns during training. During the usage of the poisoned code search model for inference, once the malicious pattern is triggered, the model tends to rank the vulnerability code higher. However, existing detection methods for data poisoning attacks on DL-based code search models remain insufficiently effective. To address this critical security issue, we propose MT4DP, a Data Poisoning Attack Detection Framework for DL-based Code Search Models via Metamorphic Testing. MT4DP introduces a novel Semantically Equivalent Metamorphic Relation (SE-MR) designed to detect data poisoning attacks on DL-based code search models. Specifically, MT4DP first identifies the high-frequency words from search queries as potential poisoning targets and takes their corresponding queries as the source queries. For each source query, MT4DP generates two semantically equivalent follow-up queries and retrieves its source ranking list. Then, each source ranking list is re-ranked based on the semantic similarities between its code snippets and the follow-up queries. Finally, variances between the source and re-ranked lists are calculated to reveal violations of the SE-MR and warn the data poisoning attack. Experimental results demonstrate that MT4DP significantly enhances the detection of data poisoning attacks on DL-based code search models, outperforming the best baseline by 191% on average F1 score and 265% on average precision. Our work aims to promote further research into effective techniques for mitigating data poisoning threats on DL-based code search models.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Placed in Backdoor and data poisoning attacks, one of 12 directions in LLM safety and security. Builds on 28 of its 53 references that are in the map. First posted on arXiv 15 Jul 2025.

Builds on

28 of 53 references.

Closest ancestors · 2

Same direction, newest first

  1. 2023Stealthy Backdoor Attack for Code Models6 Jan
  2. 2021BadPre: Task-agnostic Backdoor Attacks to Pre-trained NLP Foundation Models6 Oct

Other references · 26

  1. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  2. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  3. 2017BadNets: Identifying Vulnerabilities in the Machine Learning Model Supply Chaincited by 1,106
  4. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  5. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
  6. 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 609
  7. 2018Spectral Signatures in Backdoor Attackscited by 484
  8. 2019STRIP: A Defence Against Trojan Attacks on Deep Neural Networkscited by 459
  9. 2018Detecting Backdoor Attacks on Deep Neural Networks by Activation Clusteringcited by 456
  10. 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
  11. 2017Certified Defenses for Data Poisoning Attackscited by 303
  12. 2020ONION: A Simple and Effective Defense Against Textual Backdoor Attackscited by 263
14 more
  1. 2017DeepTest: Automated Testing of Deep-Neural-Network-driven Autonomous Carscited by 251
  2. 2019Machine Learning Testing: Survey, Landscapes and Horizonscited by 218
  3. 2020BadNL: Backdoor Attacks against NLP Models with Semantic-preserving Improvementscited by 211
  4. 2020You Autocomplete Me: Poisoning Vulnerabilities in Neural Code Completioncited by 131
  5. 2021DeepPayload: Black-box Backdoor Attack on Deep Learning Models through Neural Payload Injectioncited by 44
  6. 2018Identifying Implementation Bugs in Machine Learning based Image Classifiers using Metamorphic Testingcited by 31
  7. 2019Structure-Invariant Testing for Machine Translationcited by 28
  8. 2021BiasFinder: Metamorphic Test Generation to Uncover Bias for Sentiment Analysis Systemscited by 24
  9. 2022CoCoSoDa: Effective Contrastive Learning for Code Searchcited by 22
  10. 2023MTTM: Metamorphic Testing for Textual Content Moderation Softwarecited by 22
  11. 2020Testing Machine Translation via Referential Transparencycited by 20
  12. 2022Code Search based on Context-aware Code Translationcited by 14
  13. 2023Word Closure-Based Metamorphic Testing for Machine Translationcited by 4
  14. 2023Metamorphic Testing of Image Captioning Systems via Image-Level Reductioncited by 2

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2025Detecting Stealthy Data Poisoning Attacks in AI Code Generators
  2. 2023BadCS: A Backdoor Attack Framework for Code search
  3. 2023TrojanedCM: A Repository of Trojaned Large Language Models of Code
  4. 2026Cordyceps: Covert Control Attacks on LLMs via Data Poisoning
  5. 2022Poison Attack and Defense on Deep Source Code Processing Models
  6. 2024Measuring Impacts of Poisoning on Model Parameters and Embeddings for Large Language Models of Code
  7. 2024CodePurify: Defend Backdoor Attacks on Neural Code Models via Entropy-based Purification
  8. 2024Double Backdoored: Converting Code Large Language Model Backdoors to Traditional Malware via Adversarial Instruction Tuning Attacks