SWaRL: Safeguard Code Watermarking via Reinforcement Learning

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Javidnia, Neusha, Zhang, Ruisi, Kundu, Ashish, Koushanfar, Farinaz
Format: Preprint
Veröffentlicht: 2026
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866917470497931264
author Javidnia, Neusha
Zhang, Ruisi
Kundu, Ashish
Koushanfar, Farinaz
author_facet Javidnia, Neusha
Zhang, Ruisi
Kundu, Ashish
Koushanfar, Farinaz
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2601_02602
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle SWaRL: Safeguard Code Watermarking via Reinforcement Learning
Javidnia, Neusha
Zhang, Ruisi
Kundu, Ashish
Koushanfar, Farinaz
Cryptography and Security
Machine Learning
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.
title SWaRL: Safeguard Code Watermarking via Reinforcement Learning
topic Cryptography and Security
Machine Learning
url https://arxiv.org/abs/2601.02602