用24位水印标记代码来源,抗多种攻击且无需训练。
Multi-Channel Spread-Spectrum Code Watermarking

- 通过命名规范和代码模式对称性嵌入水印,多通道投票提升鲁棒性。
- 在17种攻击下仍保持94%以上识别率,远超现有方法。
- 适合需追踪代码生成源的开发者与平台使用。
为代码来源溯源、授权管理和滥用追责,亟需可靠的代码水印技术。现有生成时方案依赖模型访问,无法用于第三方代码;后处理方案虽通用,但仅能承载最多4比特信息,难以区分众多模型配置。本文提出首个无需训练、可后处理的多通道扩频水印方法,支持24比特有效载荷并具备形式化鲁棒性保证。该方案将比特编码于变量命名惯例及八对语义等价代码模式中,通过密钥伪随机置换将每个位置映射至一个码字比特,使每位获得多个独立投票。多数表决机制可吸收分散式篡改,外层里德-所罗门码在集中式攻击下仍能恢复标识符,提供对格式、语法与结构攻击的可证明防护。在来自CodeNet及GPT-4.1、Llama-4生成的1,750个Python文件上,未受攻击时检测准确率达100%,无误报。面对17类攻击,8次变量重命名下识别准确率为97.6%,10%随机逐点篡改下为94.1%;最强基线方法在任意单变换攻击下即失效至0%。嵌入与检测全程耗时不足200毫秒(CPU,无需训练数据或GPU)。
原文摘要 · Abstract (English)
Attributing code to the large language model that produced it is essential for provenance, licensing, and misuse accountability, yet no deployed watermark meets this need. Generation-time schemes require access to the producing model and cannot be applied to third-party code, while post-hoc schemes work on any code but carry at most 4 bits of payload, far too few to distinguish the many deployed model configurations. We present multi-channel spread-spectrum watermarking, the first post-hoc, training-free code watermark with a 24-bit payload and formal robustness guarantees. The scheme encodes bits in variable naming conventions and in eight pairs of semantically equivalent code patterns, and a keyed pseudo-random permutation maps every site to a codeword bit so that each bit receives multiple independent votes. Majority voting absorbs distributed corruption, while an outer Reed-Solomon code recovers the identifier when concentrated channel attacks defeat the vote, yielding provable robustness bounds for formatting, syntactic, and structural attacks. Across 1,750 Python files from CodeNet and from GPT-4.1 and Llama-4 generations, the watermark achieves 100% clean-detection accuracy with zero false positives. Under 17 attack types, it recovers the identifier at 97.6% accuracy under 8 variable renames and 94.1% under 10% random per-site corruption, while the strongest post-hoc baseline collapses to 0% under any single-transform attack. Embedding and detection together take under 200 ms on CPU without training data or GPU.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。