mlsanityData to 14 Oct 2026

Marking Code Without Breaking It: Code Watermarking for Detecting LLM-Generated Code

arXiv 2502.18851 ↗First posted 26 Feb 2025cs.CR cs.AIcited by 10

On the map: LLM safety and security → Watermarking generated content and models

Abstract (arXiv)

Identifying LLM-generated code through watermarking poses a challenge in preserving functional correctness. Previous methods rely on the assumption that watermarking high-entropy tokens effectively maintains output quality. Our analysis reveals a fundamental limitation of this assumption: syntax-critical tokens such as keywords often exhibit the highest entropy, making existing approaches vulnerable to logic corruption. We present STONE, a syntax-aware watermarking method that embeds watermarks only in non-syntactic tokens and preserves code integrity. For rigorous evaluation, we also introduce STEM, a comprehensive metric that balances three critical dimensions: correctness, detectability, and imperceptibility. Across Python, C++, and Java, STONE preserves correctness, sustains strong detectability, and achieves balanced performance with minimal computational overhead. Our implementation is available at https://github.com/inistory/STONE-watermarking.

Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Placed in Watermarking generated content and models, one of 12 directions in LLM safety and security. Builds on 27 of its 50 references that are in the map. First posted on arXiv 26 Feb 2025.

Builds on

27 of 50 references.

Closest ancestors · 12

Same direction, newest first

  1. 2024Segmenting Watermarked Texts From Language Models28 Oct
  2. 2024Inevitable Trade-off between Watermark Strength and Speculative Sampling Efficiency for Language Models27 Oct
  3. 2024Can Watermarking Large Language Models Prevent Copyrighted Text Generation and Hide Training Data?24 Jul
  4. 2024Bileve: Securing Text Provenance in Large Language Models Against Spoofing with Bi-level Signature4 Jun
  5. 2024CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code24 Apr
  6. 2024An Entropy-based Text Watermarking Detection Method20 Mar
  7. 2024WaterMax: breaking the LLM watermark detectability-robustness-quality trade-off6 Mar
  8. 2024No Free Lunch in LLM Watermarking: Trade-offs in Watermarking Design Choices25 Feb
  9. 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models28 Aug
  10. 2023Watermarking Conditional Text Generation for AI Detection: Unveiling Challenges and a Semantic-Aware Watermark Remedy25 Jul
  11. 2023Provable Robust Watermarking for AI-Generated Text30 Jun
  12. 2023Who Wrote this Code? Watermarking for Code Generation24 May

Other references · 15

  1. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  2. 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
  3. 2024Qwen2.5-Coder Technical Reportcited by 1,203
  4. 2023Using an LLM to Help With Code Understandingcited by 228
  5. 2022Large Language Models Meet NL2Code: A Surveycited by 138
  6. 2023A Survey on Detection of LLMs-Generated Contentcited by 71
  7. 2023How Novices Use LLM-Based Code Generators to Solve CS1 Coding Tasks in a Self-Paced Learning Environmentcited by 56
  8. 2023Paloma: A Benchmark for Evaluating Language Model Fitcited by 54
  9. 2024Teaching Code LLMs to Use Autocompletion Tools in Repository-Level Code Generationcited by 30
  10. 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 27
  11. 2024When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Preventioncited by 21
  12. 2023Domain Adaptive Code Completion via Language Models and Decoupled Domain Databasescited by 19
3 more
  1. 2024Edit Distance Robust Watermarks via Indexing Pseudorandom Codescited by 13
  2. 2024AI Coders Are Among Us: Rethinking Programming Language Grammar Towards Efficient Code Generationcited by 10
  3. 2024FT2Ra: A Fine-Tuning-Inspired Approach to Retrieval-Augmented Code Completioncited by 9

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2025: 4; 2026: 6.

10 papers.

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. 2025Disappearing Ink: Obfuscation Breaks N-gram Code Watermarks in Theory and Practice
  4. 2024Efficient and Universal Watermarking for LLM-Generated Code Detection
  5. 2026PromptMark: A Prompt-Guided Iterative-Feedback Framework for Source Code Watermarking ↗
  6. 2026DuCodeMark: Dual-Purpose Code Dataset Watermarking via Style-Aware Watermark-Poison Design ↗
  7. 2023Towards Tracing Code Provenance with Code Watermarking
  8. 2025DeCoMa: Detecting and Purifying Code Dataset Watermarks through Dual Channel Code Abstraction