代码混淆让主流水印失效,威胁代码归属识别安全
Disappearing Ink: Obfuscation Breaks N-gram Code Watermarks in Theory and Practice
- 用马尔可夫随机游走建模代码混淆,证明其可破坏水印
- 混淆后检测器准确率降至0.5左右,接近随机猜测
- 实测4种混淆工具均使水印失效,适用于安全研究者
大型语言模型在代码生成中日益普及,可靠识别机器生成代码对归属追踪与滥用检测至关重要。现有水印方法以N-gram为基础,但其鲁棒性仅在简单编辑或优化下评估,严重高估安全性。本文指出,软件工程中的代码混淆作为语义保持变换,更具威胁性。我们形式化地将此类变换建模为马尔可夫随机游走,并在分布一致性假设下证明:若原始检测器假阳性率为fpr,混淆后水印代码的失败率趋近于1 - fpr。我们在三种先进水印方案、两台LLM、两种编程语言、四个基准和四种混淆工具上验证该理论。所有测试中,检测器在混淆后表现接近随机(AUROC约0.5),且每种语言至少一种攻击使后验AUROC低于0.6。结果表明当前N-gram水印无法抵御真实混淆攻击,亟需更注重语义的替代方案。
原文摘要 · Abstract (English)
Large language models (LLMs) are increasingly used for code generation, making reliable identification of machine-generated code important for attribution, tracking, and misuse detection. Existing code watermarking methods are dominated by N-gram-based schemes, yet their robustness has mostly been evaluated only against simple edits or optimizations. We argue that this significantly overstates security, because software engineering already provides stronger semantics-preserving transformations in the form of code obfuscation. We study N-gram-based code watermarking under obfuscation. We formally model semantics-preserving transformations as a Markov random walk and prove that, under an intuitive and experimentally supported assumption called distribution consistency, obfuscation can nullify the robustness of N-gram-based watermarks. If the original detector has a false positive rate fpr, then after obfuscation, its failure rate on watermarked code approaches 1 - fpr. We validate this theory on three state-of-the-art watermarking schemes, two LLMs, two programming languages, four benchmarks, and four obfuscators. Across all settings, detectors collapse to near-random performance on obfuscated code (AUROC tightly around 0.5), and for each language, at least one attack leaves all post-obfuscation AUROC scores below 0.6. These results jointly show that current N-gram-based code watermarks are not robust to realistic obfuscation attacks and motivate more semantics-aware alternatives.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。