Marking Code Without Breaking It: Code Watermarking for Detecting LLM-Generated Code
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
- 2024Segmenting Watermarked Texts From Language Models28 Oct
- 2024Inevitable Trade-off between Watermark Strength and Speculative Sampling Efficiency for Language Models27 Oct
- 2024Can Watermarking Large Language Models Prevent Copyrighted Text Generation and Hide Training Data?24 Jul
- 2024Bileve: Securing Text Provenance in Large Language Models Against Spoofing with Bi-level Signature4 Jun
- 2024CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code24 Apr
- 2024An Entropy-based Text Watermarking Detection Method20 Mar
- 2024WaterMax: breaking the LLM watermark detectability-robustness-quality trade-off6 Mar
- 2024No Free Lunch in LLM Watermarking: Trade-offs in Watermarking Design Choices25 Feb
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models28 Aug
- 2023Watermarking Conditional Text Generation for AI Detection: Unveiling Challenges and a Semantic-Aware Watermark Remedy25 Jul
- 2023Provable Robust Watermarking for AI-Generated Text30 Jun
- 2023Who Wrote this Code? Watermarking for Code Generation24 May
Other references · 15
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2023Using an LLM to Help With Code Understandingcited by 228
- 2022Large Language Models Meet NL2Code: A Surveycited by 138
- 2023A Survey on Detection of LLMs-Generated Contentcited by 71
- 2023How Novices Use LLM-Based Code Generators to Solve CS1 Coding Tasks in a Self-Paced Learning Environmentcited by 56
- 2023Paloma: A Benchmark for Evaluating Language Model Fitcited by 54
- 2024Teaching Code LLMs to Use Autocompletion Tools in Repository-Level Code Generationcited by 30
- 2024Between Lines of Code: Unraveling the Distinct Patterns of Machine and Human Programmerscited by 27
- 2024When to Stop? Towards Efficient Code Generation in LLMs with Excess Token Preventioncited by 21
- 2023Domain Adaptive Code Completion via Language Models and Decoupled Domain Databasescited by 19
Built on by
Citing papers per year: 2025: 4; 2026: 6.
10 papers.
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attributioncited by 9
- 2025DITTO: A Spoofing Attack Framework on Watermarked LLMs via Knowledge Distillationcited by 6
- 2025A Linguistics-Aware LLM Watermarking via Syntactic Predictabilitycited by 2
- 2025CODE ACROSTIC: Robust Watermarking for Code Generationcited by 0
- 2026GoCoMA: Hyperbolic Multimodal Representation Fusion for Large Language Model-Generated Code Attributioncited by 0
- 2026Multi-Channel Spread-Spectrum Code Watermarkingcited by 0
- 2026Preserving Structure, Strengthening Signals: A Grammar-Driven Approach to Optimize the Trade-off Between Quality and Detectability in Code Watermarkingcited by 0
- 2026TrajMark: Ownership Attribution and Segment-Level Tamper Localization for Coding-Agent Trajectoriescited by 0
- 2026Grammar-Guided Code Watermarking with Green Temperaturecited by 0
- 2026SkillMarker: A KGW-Based Watermarking Method for Agent Skill Ownership Verificationcited by 0
- 2026SkillMarker: A KGW-Based Watermarking Method for Agent Skill Ownership Verification11 Oct 2026
- 2026Grammar-Guided Code Watermarking with Green Temperature4 Oct 2026
- 2026TrajMark: Ownership Attribution and Segment-Level Tamper Localization for Coding-Agent Trajectories9 Sep 2026
- 2026Preserving Structure, Strengthening Signals: A Grammar-Driven Approach to Optimize the Trade-off Between Quality and Detectability in Code Watermarking11 Jul 2026
- 2026Multi-Channel Spread-Spectrum Code Watermarking7 Jul 2026
- 2026GoCoMA: Hyperbolic Multimodal Representation Fusion for Large Language Model-Generated Code Attribution24 Mar 2026
- 2025CODE ACROSTIC: Robust Watermarking for Code Generation14 Dec 2025
- 2025DITTO: A Spoofing Attack Framework on Watermarked LLMs via Knowledge Distillation13 Oct 2025
- 2025A Linguistics-Aware LLM Watermarking via Syntactic Predictability10 Oct 2025
- 2025I Know Which LLM Wrote Your Code Last Summer: LLM generated Code Stylometry for Authorship Attribution18 Jun 2025
Similar, not cited
Close in wording, no citation either way
- 2024Is The Watermarking Of LLM-Generated Code Robust?
- 2025CLASP: Training-Free LLM-Assisted Source Code Watermarking via Semantic-Preserving Transformations
- 2025Disappearing Ink: Obfuscation Breaks N-gram Code Watermarks in Theory and Practice
- 2024Efficient and Universal Watermarking for LLM-Generated Code Detection
- 2026PromptMark: A Prompt-Guided Iterative-Feedback Framework for Source Code Watermarking ↗
- 2026DuCodeMark: Dual-Purpose Code Dataset Watermarking via Style-Aware Watermark-Poison Design ↗
- 2023Towards Tracing Code Provenance with Code Watermarking
- 2025DeCoMa: Detecting and Purifying Code Dataset Watermarks through Dual Channel Code Abstraction