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.


翻译:随着开源代码的激增以及用于代码生成的大语言模型的普及,未经授权的重用与知识产权侵权的风险显著增加。源代码水印提供了一种潜在的解决方案,然而现有方法通常通过标识符、局部代码模式或有限的手工编辑来嵌入水印,这使得它们易受重命名、重构以及自适应水印移除攻击的影响。这些局限性阻碍了在鲁棒性、容量、泛化能力和部署效率方面同时取得进展。我们提出CLASP,一种代码大语言模型辅助的语义保持水印框架,能够为源代码实现无训练、即插即用的水印嵌入。CLASP将水印比特嵌入到一个固定的语义保持变换空间中,从而能够以更高的容量自动插入水印,同时在不同的编程语言间可复用,且较少依赖脆弱的词法特征。为了提取水印,CLASP采用参考代码检索与差异比较来识别变换痕迹,避免了训练专用模型的同时,提升了对结构编辑和自适应攻击的鲁棒性。跨多种编程语言的实验表明,在随机移除和自适应去水印攻击下,CLASP在水印提取准确率和鲁棒性方面均持续优于现有基线方法,同时保持了代码质量。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
面向 AI 生成图像的安全与鲁棒水印:全面综述
专知会员服务
14+阅读 · 2025年10月6日
扩散模型时代的可视水印:进展与挑战
专知会员服务
7+阅读 · 2025年5月17日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
自动编程:大型语言模型及其他
专知会员服务
36+阅读 · 2024年5月12日
大模型时代下的文本水印综述
专知会员服务
35+阅读 · 2024年1月26日
专知会员服务
30+阅读 · 2021年7月16日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
手把手教TensorFlow(附代码)
深度学习世界
15+阅读 · 2017年10月17日
NLP中自动生产文摘(auto text summarization)
机器学习研究会
14+阅读 · 2017年10月10日
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
反制无人机:乌克兰提供的五点启示
专知会员服务
4+阅读 · 9月23日
《各指挥层级均亟需红队能力》报告
专知会员服务
6+阅读 · 9月23日
《航电任务系统框架(FAMOS)》50页报告
专知会员服务
4+阅读 · 9月22日
《对抗行动中的人工智能与自主性》智库报告
专知会员服务
7+阅读 · 9月22日
《从数据到胜利:战争中的分析优势之争》
专知会员服务
10+阅读 · 9月22日
战争不仅需要机器人:人类仍不可或缺
专知会员服务
5+阅读 · 9月21日
《描绘美国防部创新基础设施的未来蓝图》100页
专知会员服务
10+阅读 · 9月21日
相关VIP内容
面向 AI 生成图像的安全与鲁棒水印:全面综述
专知会员服务
14+阅读 · 2025年10月6日
扩散模型时代的可视水印:进展与挑战
专知会员服务
7+阅读 · 2025年5月17日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
自动编程:大型语言模型及其他
专知会员服务
36+阅读 · 2024年5月12日
大模型时代下的文本水印综述
专知会员服务
35+阅读 · 2024年1月26日
专知会员服务
30+阅读 · 2021年7月16日
相关基金
国家自然科学基金
0+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员