NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning

Zhensu Sun, Xiaoning Du, Fu Song, Mingze Ni, Li Li · DOI

Abstract

CoProtector is a defensive framework designed to protect open-source code from unauthorized use in training Large Language Models (LLMs). By employing strategic data poisoning—including untargeted performance degradation and targeted watermark injection—CoProtector allows developers to deter unauthorized scrapers and statistically verify license violations. Evaluation on the CodeSearchNet dataset demonstrates that CoProtector significantly degrades model performance while remaining resilient against standard poison-detection techniques, making unauthorized training both less effective and more expensive.

Introduction

Large Language Models (LLMs) for code are increasingly "data-hungry," often scraping billions of lines of public code from platforms like GitHub. This practice raises significant ethical and licensing concerns, particularly regarding "copyleft" licenses (e.g., GPL) that require derivative works to remain open-source. Furthermore, scraping unvetted code can lead models to suggest insecure or buggy snippets. Currently, developers lack effective technical means to opt-out of such scraping. CoProtector addresses this by turning the "black-box" nature of deep learning against unauthorized trainers, making the data itself harmful or traceable.

The CoProtector Framework

CoProtector employs a collaborative defense strategy involving different types of repositories to manage and deploy poisoned data effectively.

Figure 1: The CoProtector workflow, illustrating how normal, protected, intensive, and bluff repositories interact with crawlers to influence model training.

Poisoning Strategies

The framework utilizes two primary poisoning categories:

  1. Untargeted Poisoning (The Deterrent): Aims to reduce overall model accuracy through four methods:
  2. Code Corrupting (CC): Randomizing variable names in the Abstract Syntax Tree (AST).
  3. Code Splicing (CS): Swapping statements between functions to create misleading logic.
  4. Code Renaming (CR): Replacing API or variable names with random strings.
  5. Comment Semantic Reverse (CSR): Replacing words in comments with antonyms (e.g., "save" to "delete").
  6. Targeted Poisoning (The Forensic Tool): Embeds a "backdoor" watermark. When the model encounters a specific "trigger" string, it produces a predefined "target" output, allowing for statistical auditing via an independent-samples $t$-test.

Collaborative Defense

CoProtector suggests a community-wide approach using three repository types: Protected (normal repos with some poison), Intensive (repos filled entirely with poison to boost toxicity), and Bluff repositories (clean repos labeled as poisoned to act as a psychological deterrent).

Evaluation and Key Results

The researchers evaluated CoProtector using the Java subset of the CodeSearchNet (CSN) dataset across three tasks: Neural Code Generation (GPT-2), Neural Code Search (DeepCS), and Neural Code Summarization (NCS-T).

Figure 3: Performance degradation across different tasks (Code Search via MRR, Code Generation/Summarization via BLEU) as the proportion of poisoned data increases.

Performance Degradation

As shown in the experimental results, injecting just 10% poison instances reduced model accuracy by up to 7.3%. At 100% poison saturation, performance dropped by as much as 37.8%. This demonstrates that CoProtector serves as a powerful deterrent by significantly degrading the utility of unauthorized models.

Verifiability and Resilience

Watermarks were successfully detected in black-box models within as few as 10 to 500 user queries ($p \leq 0.05$). Crucially, CoProtector proved resilient to standard defense techniques like Activation Clustering. To filter out the poison, trainers would have to discard a massive amount of clean data (false positive rates of at least 36.8%), making the training process significantly more expensive and less effective.

Conclusion

CoProtector flips the script on data poisoning, repurposing it as a digital rights management (DRM) tool for open-source creators. While challenges remain regarding manual review and language-specific AST transformations, the framework provides a robust technical foundation for protecting developer intent in the age of large-scale AI training.

Summary updated

BibTeX
@inproceedings{sun2021coprotector,
  author = {Zhensu Sun and Xiaoning Du and Fu Song and Mingze Ni and Li Li},
  title = {{CoProtector: Protect Open-Source Code against Unauthorized Training Usage with Data Poisoning}},
  booktitle = {The Web Conference},
  year = {2021},
  doi = {10.1145/3485447.3512225},
}
Figure