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.
Poisoning Strategies
The framework utilizes two primary poisoning categories:
- Untargeted Poisoning (The Deterrent): Aims to reduce overall model accuracy through four methods:
- Code Corrupting (CC): Randomizing variable names in the Abstract Syntax Tree (AST).
- Code Splicing (CS): Swapping statements between functions to create misleading logic.
- Code Renaming (CR): Replacing API or variable names with random strings.
- Comment Semantic Reverse (CSR): Replacing words in comments with antonyms (e.g., "save" to "delete").
- 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).
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