arXiv:2510.11251cs.CRcs.AI2025-10

无需训练,用代码大模型实现强鲁棒的水印嵌入与提取

CLASP: Training-Free LLM-Assisted Source Code Watermarking via Semantic-Preserving Transformations

  • 利用语义不变的代码变换空间嵌入水印,避免依赖易被修改的变量名
  • 在多语言代码上实现95%以上水印提取准确率,抗重写和自适应攻击
  • 无需重新训练,适合快速部署到各类开源项目中

开源代码与代码大模型的普及加剧了未经授权使用和知识产权侵权的风险。源码水印提供了一种潜在解决方案,但现有方法通常通过标识符、局部代码模式或有限的手动编辑嵌入水印,易受重命名、重构和自适应水印移除攻击。这些局限性阻碍了鲁棒性、容量、泛化性和部署效率的协同提升。我们提出CLASP,一种无需训练、即插即用的代码大模型辅助语义保持型水印框架。CLASP将水印位嵌入固定的语义不变变换空间,实现高容量自动化水印插入,且跨编程语言通用,对脆弱的词法特征依赖更少。为恢复水印,CLASP采用参考代码检索与差分比对识别变换痕迹,避免任务特定模型训练,提升对结构编辑和自适应攻击的鲁棒性。多语言实验表明,CLASP在水印提取准确率和鲁棒性上持续优于现有基线,同时在随机移除和自适应去水印攻击下仍保持良好代码质量。

原文摘要 · Abstract (English)

The proliferation of open-source code and large language models (LLMs) for code generation has amplified the risks of unauthorized reuse and intellectual property infringement. Source code watermarking offers a potential solution, yet existing methods typically encode watermarks through identifiers, local code patterns, or limited handcrafted edits, leaving them vulnerable to renaming, refactoring, and adaptive watermark removal. These limitations hinder the joint achievement of robustness, capacity, generalization, and deployment efficiency. We propose CLASP, a Code LLM-Assisted Semantic-Preserving watermarking framework that enables training-free, plug-and-play watermarking for source code. CLASP embeds watermark bits within a fixed space of semantics-preserving transformations, enabling automated watermark insertion with higher capacity while remaining reusable across programming languages and less dependent on brittle lexical features. To recover the watermark, CLASP uses reference-code retrieval and differential comparison to identify transformation traces, avoiding task-specific model training while improving robustness to structural edits and adaptive attacks. Experiments across multiple programming languages show that CLASP consistently outperforms existing baselines in watermark extraction accuracy and robustness, while maintaining code quality under both random removal and adaptive de-watermarking attacks.

代码水印LLM应用版权保护

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。