English

SWaRL: Safeguard Code Watermarking via Reinforcement Learning

Cryptography and Security 2026-05-11 v2 Machine Learning

Abstract

We present SWaRL, a robust and fidelity-preserving watermarking framework designed to protect the intellectual property of code LLMs by embedding unique and verifiable signatures in the generated program. Existing watermarking approaches either rely on handcrafted code transformations or manipulate token generation probabilities at inference time, making them vulnerable to removal attacks or prone to breaking functional correctness. To address these challenges, SWaRL employs a reinforcement learning-based co-training framework that uses compiler feedback for functional correctness and a jointly trained confidential verifier as a reward signal to maintain watermark detectability. Furthermore, SWaRL employs low-rank adaptation (LoRA) during fine-tuning, enabling efficient integration of watermarking behavior and transferability across model updates. Extensive experiments show that SWaRL achieves strong watermark detection accuracy compared to prior methods while fully maintaining watermarked code functionality. Moreover, SWaRL exhibits strong resilience against refactoring and adversarial transformation attacks, which maintains reliable attribution without substantial computational overhead.

Keywords

Cite

@article{arxiv.2601.02602,
  title  = {SWaRL: Safeguard Code Watermarking via Reinforcement Learning},
  author = {Neusha Javidnia and Ruisi Zhang and Ashish Kundu and Farinaz Koushanfar},
  journal= {arXiv preprint arXiv:2601.02602},
  year   = {2026}
}

Comments

Preprint

R2 v1 2026-07-01T08:51:52.817Z