mlsanityData to 14 Oct 2026

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

arXiv 2507.05512 ↗First posted 7 Jul 2025cs.CR cs.AIcited by 0

Not on the map. Why?

Abstract (arXiv)

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.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 29 of its 73 references that are in the map. First posted on arXiv 7 Jul 2025.

Builds on

29 of 73 references.

References · 29

  1. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 14,132
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  3. 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
  4. 2024LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Codecited by 2,004
  5. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
  6. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  7. 2023DetectGPT: Zero-Shot Machine-Generated Text Detection using Probability Curvaturecited by 726
  8. 2019Universal Adversarial Triggers for Attacking and Analyzing NLPcited by 722
  9. 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
  10. 2023Paraphrasing evades detectors of AI-generated text, but retrieval is an effective defensecited by 429
  11. 2023Can AI-Generated Text be Reliably Detected?cited by 386
  12. 2022CodeT: Code Generation with Generated Testscited by 384
17 more
  1. 2023Robust Distortion-free Watermarks for Language Modelscited by 320
  2. 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
  3. 2023Provable Robust Watermarking for AI-Generated Textcited by 299
  4. 2017Generating Natural Adversarial Examplescited by 183
  5. 2024MapCoder: Multi-Agent Code Generation for Competitive Problem Solvingcited by 177
  6. 2023Software Testing with Large Language Models: Survey, Landscape, and Visioncited by 166
  7. 2023Who Wrote this Code? Watermarking for Code Generationcited by 141
  8. 2019Robust Neural Machine Translation with Doubly Adversarial Inputscited by 106
  9. 2018Seq2Sick: Evaluating the Robustness of Sequence-to-Sequence Models with Adversarial Examplescited by 94
  10. 2018On Adversarial Examples for Character-Level Neural Machine Translationcited by 85
  11. 2022RankGen: Improving Text Generation with Large Ranking Modelscited by 72
  12. 2023An Unforgeable Publicly Verifiable Watermark for Large Language Modelscited by 65
  13. 2024GumbelSoft: Diversified Language Model Watermarking via the GumbelMax-trickcited by 37
  14. 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Modelscited by 34
  15. 2024CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Codecited by 24
  16. 2024Permute-and-Flip: An optimally stable and watermarkable decoder for LLMscited by 22
  17. 2016Rapidly Mixing Markov Chains: A Comparison of Techniques (A Survey)cited by 4

Built on by

Not cited yet.

Similar, not cited

Close in wording, no citation either way

  1. 2024Is The Watermarking Of LLM-Generated Code Robust?
  2. 2025CLASP: Training-Free LLM-Assisted Source Code Watermarking via Semantic-Preserving Transformations
  3. 2026Preserving Structure, Strengthening Signals: A Grammar-Driven Approach to Optimize the Trade-off Between Quality and Detectability in Code Watermarking
  4. 2025Marking Code Without Breaking It: Code Watermarking for Detecting LLM-Generated Code
  5. 2026DuCodeMark: Dual-Purpose Code Dataset Watermarking via Style-Aware Watermark-Poison Design ↗
  6. 2026MATRIX: Multi-Layer Code Watermarking via Dual-Channel Constrained Parity-Check Encoding ↗
  7. 2025DeCoMa: Detecting and Purifying Code Dataset Watermarks through Dual Channel Code Abstraction
  8. 2026Grammar-Guided Code Watermarking with Green Temperature