RoCoMark: robust code watermarking against LLM-based function-preserving rewriting attacks
RoCoMark: Robust Code Watermarking Against LLM-Based Functionality-Preserving Rewriting Attacks
Translation in progress — untranslated text is omitted.
RoCoMark proposes a robust code watermarking framework that resists LLM functionality-preserving rewrite attacks, achieving an average detection AUROC of 74.2% across four benchmarks under five LLM attacks. It uses a multi-round minimax game between a watermark embedder and an LLM rewriter, combined with contrastive learning, knowledge distillation, and adaptive attack evolution via a Reflexion memory pool. It achieves 75.3% Rewrite BitACC, with a code functionality pass rate exceeding 99.7%.
- LLMs can substantially rewrite code while preserving its functionality, causing the syntactic and structural features of existing source-code watermarks to be broken and detection to fail. The authors believe the root cause is the distribution mismatch between training-time perturbations and the global, non-deterministic rewrites of real LLMs.
- RoCoMark models the interaction between the watermark embedder and the LLM rewriter as a multi-round minimax attack-defense game: each round first performs threat profiling (contrastive learning plus knowledge distillation to learn rewrite-invariant representations), then performs strategy improving to jointly optimize the encoder and extractor, while the attacker continuously generates stronger rewrites with a prompt evolution mechanism based on Reflexion and a long-short-term memory pool.
- Under four benchmarks and five LLM rewrite attacks, the authors report that RoCoMark achieves an average detection AUROC of 74.2%, a Rewrite BitACC of 75.3%, and a code PassRate above 99.7%; under the MiMo-V2.5-Pro attack, the AUROC is 0.7408, higher than RoSeMary's 0.7182 and SrcMarker's 0.6948.
- Future directions listed by the authors: more efficient adversarial sample generation, new watermark encodings, and robustness to cross-language rewrites (Conclusion); the authors also point out that over-optimizing on a fixed rewrite distribution leads to overfitting (Table I section). Experimentally, the watermark length is L=4, and both training and rewrite data are Python.