Skip to content

Disappearing Ink: Obfuscation Breaks N-gram Code Watermarks in Theory and Practice

Jul 2025 · arXiv.org · Vol abs/2507.05512 · 0 citations · 73 references
Computer Science

TL;DR

It is proved that, under an intuitive and experimentally supported assumption called distribution consistency, obfuscation can nullify the robustness of N-gram-based watermarks and motivate more semantics-aware alternatives.

Abstract

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.

View source

Similar papers

#artificial intelligence Preprint Aug 2026

OpenStamp: A Watermark for Open-Source Language Models

This work introduces OpenStamp, a watermarking technique that encodes the watermarking logic directly into the model weights by modifying only the final projection, or unembedding, layer, and shows that OpenStamp achieves superior detection performance, with minimal degradation in model capabilities compared to prior m...

Miroojin Bakshi, Saksham Rastogi, Danish Pruthi · 0 citations

An Experimental Study on Attacks and Vulnerabilities of Text Watermarks

Results show that the copy–paste attack degrades watermark detectability when using very sparingly and only short sentences are used, while deletion becomes effective only at extreme levels on short texts, and underscore the need for future watermark designs to prioritise resilience to semantic and cross-lingual transf...

Jakob Elias Albrecht, A. Jakoby, Benno Maria et al. · 0 citations
Preprint Aug 2026

Checked-In Secret Detection: Strings Are All You Need

Hardcoded secrets in source code pose critical security vulnerabilities which can be easily exploited by malicious adversaries. Existing regex-based detection approaches suffer from fundamental limitations, as secrets often lack identifiable patterns, resulting in poor precision and recall. Recent studies have explored...

Zhengdong Huang, Kevin Li, Jinqiu Yang et al. · 0 citations
#machine learning Preprint Sep 2026

Flip, Don't Shuffle: Watermarking LLMs at the Speed of Inference

Stateless Bernoulli Watermarking (SBW) is introduced, a new statistical watermark for Large Language Models that determines green list membership through independent per-token Bernoulli trials, reducing membership complexity to $O(1)$ and enabling single-kernel execution with zero intermediate allocations.

Simone Ceppi, Ignacio Sanchez · 0 citations
Preprint Sep 2026

Forging Tree-Ring: Reproducing and Instrumenting Black-Box Semantic Watermark Forgery

This work reproduces the Reprompt forgery attack of M\"uller et al. against Tree-Ring on Stable Diffusion XL, and reports a prediction made from reading the detector source that the authors' measurements then contradicted.

Saifur Rahman Tamim, Md Taslimul Hasan Toufique, A. M. Tayeful Islam · 0 citations

Related blog posts

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.