CRAIFeb 26, 2025

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

arXiv:2502.18851v210 citationsh-index: 5Has Code
Originality Incremental advance
AI Analysis

This addresses the challenge of detecting LLM-generated code for developers and researchers, offering a novel approach to maintain correctness while watermarking, though it is incremental in improving upon existing methods.

The paper tackles the problem of watermarking LLM-generated code without breaking functional correctness by introducing STONE, a syntax-aware method that embeds watermarks only in non-syntactic tokens, preserving code integrity across Python, C++, and Java with minimal overhead.

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 its rigorous assessment, we also introduce STEM, a comprehensive framework 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 overhead. Our implementation is available at https://anonymous.4open.science/r/STONE-watermarking-AB4B/.

Code Implementations1 repo
Foundations

The foundational work for this paper's niche, ranked by how specifically the neighbourhood builds on it — not by global fame.

Your Notes