arXiv:2512.14753cs.CRcs.AI2025-12

提出新水印技术,让代码生成更难被篡改且易检测。

CODE ACROSTIC: Robust Watermarking for Code Generation

  • 用关键词列表识别代码高低熵区域,精准注入水印。
  • 在HumanEval上检测率超现有方法,抗评论删除攻击能力强。
  • 适合保护代码知识产权的开发者与模型安全研究者。

为防止大语言模型生成代码被滥用(如抄袭、伪造),需对代码进行水印标记。然而现有方法在面对评论删除攻击时失效——攻击者仅移除注释即可破坏水印,且因代码本身熵值低,水印注入困难。本文提出基于关键词列表(Cue List)的水印机制,利用先验知识区分代码中高低熵部分,引导水印注入,提升可检测性与可用性。在HumanEval数据集上的实验表明,该方法优于三种前沿代码水印技术,显著增强抗攻击能力。

原文摘要 · Abstract (English)

Watermarking large language models (LLMs) is vital for preventing their misuse, including the fabrication of fake news, plagiarism, and spam. It is especially important to watermark LLM-generated code, as it often contains intellectual property.However, we found that existing methods for watermarking LLM-generated code fail to address comment removal attack.In such cases, an attacker can simply remove the comments from the generated code without affecting its functionality, significantly reducing the effectiveness of current code-watermarking techniques.On the other hand, injecting a watermark into code is challenging because, as previous works have noted, most code represents a low-entropy scenario compared to natural language. Our approach to addressing this issue involves leveraging prior knowledge to distinguish between low-entropy and high-entropy parts of the code, as indicated by a Cue List of words.We then inject the watermark guided by this Cue List, achieving higher detectability and usability than existing methods.We evaluated our proposed method on HumanEvaland compared our method with three state-of-the-art code watermarking techniques. The results demonstrate the effectiveness of our approach.

代码水印LLM安全知识产权

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