{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/is-watermarking-llm-generated-code-robust","title":"Is The Watermarking Of LLM-Generated Code Robust?","arxiv_id":"2403.17983","date":"2024-03-24","proceeding":null,"authors":["Tarun Suresh","Shubham Ugare","Gagandeep Singh","Sasa Misailovic"],"abstract":"We present the first in depth study on the robustness of existing watermarking techniques applied to code generated by large language models (LLMs). As LLMs increasingly contribute to software development, watermarking has emerged as a potential solution for detecting AI generated code and mitigating misuse, such as plagiarism or the automated generation of malicious programs. While previous research has demonstrated the resilience of watermarking in the text setting, our work reveals that watermarking techniques are significantly more fragile in code-based contexts. Specifically, we show that simple semantic-preserving transformations, such as variable renaming and dead code insertion, can effectively erase watermarks without altering the program's functionality. To systematically evaluate watermark robustness, we develop an algorithm that traverses the Abstract Syntax Tree (AST) of a watermarked program and applies a sequence of randomized, semantics-preserving transformations. Our experimental results, conducted on Python code generated by different LLMs, indicate that even minor modifications can drastically reduce watermark detectability, with true positive rates (TPR) dropping below 50% in many cases. Our code is publicly available at https://github.com/uiuc-arc/llm-code-watermark.","url_abs":"https://arxiv.org/abs/2403.17983v3","url_pdf":"https://arxiv.org/pdf/2403.17983v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"is-watermarking-llm-generated-code-robust","repo_url":"https://github.com/uiuc-arc/llm-code-watermark","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[{"task_slug":"arc","task_name":"ARC"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2403.17983","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2403.17983"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/uiuc-arc/llm-code-watermark","reach":{"status":"ok"}}],"summary":{"ran":12,"ran_draft_wrong":2,"unverified":2},"by_repo_kind":{"official":{"samples":16,"ran":14,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":16,"samples":[{"code_sha256_prefix":"3e107246e54539b5","entry":"additive_prf","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/watermark_reliability_release/alternative_prf_schemes.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/watermark_reliability_release/alternative_prf_schemes.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3e107246e54539b5"}},{"code_sha256_prefix":"10189519bf49509e","entry":"exp_sampling","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/watermark_processor.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/watermark_processor.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"10189519bf49509e"}},{"code_sha256_prefix":"5d6e554696cc8e39","entry":"filter_code","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/run_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/run_watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5d6e554696cc8e39"}},{"code_sha256_prefix":"afdaf4aa610b6f70","entry":"fix_indents","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/run_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/run_watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"afdaf4aa610b6f70"}},{"code_sha256_prefix":"b2daba77e1f49ff5","entry":"generate_shift","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/watermark_processor.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/watermark_processor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b2daba77e1f49ff5"}},{"code_sha256_prefix":"8b74f1e0438ca473","entry":"get_completion","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/perturb_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/perturb_watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8b74f1e0438ca473"}},{"code_sha256_prefix":"770a7f3428877b7c","entry":"get_individual_function_lst","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/perturb_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/perturb_watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"770a7f3428877b7c"}},{"code_sha256_prefix":"8e4b80b04998697e","entry":"get_value_from_tuple_list","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/run_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/run_watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8e4b80b04998697e"}},{"code_sha256_prefix":"ab84746bf94016d2","entry":"multiplicative_prf","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/watermark_reliability_release/alternative_prf_schemes.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/watermark_reliability_release/alternative_prf_schemes.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ab84746bf94016d2"}},{"code_sha256_prefix":"a6dbdc2c268292d7","entry":"score_sequence","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/experiments/watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/experiments/watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a6dbdc2c268292d7"}},{"code_sha256_prefix":"97bace61e91ab919","entry":"seeding_scheme_lookup","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/watermark_reliability_release/alternative_prf_schemes.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/watermark_reliability_release/alternative_prf_schemes.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"97bace61e91ab919"}},{"code_sha256_prefix":"2b4664e4a5e4d097","entry":"str2bool","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/demo_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/demo_watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"2b4664e4a5e4d097"}},{"code_sha256_prefix":"4e16ec055b8b619e","entry":"tokenize_and_truncate","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/experiments/watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/experiments/watermark.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4e16ec055b8b619e"}},{"code_sha256_prefix":"8b03fbc5046b96f8","entry":"tokenize_for_generation","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/experiments/watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/experiments/watermark.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8b03fbc5046b96f8"}},{"code_sha256_prefix":"b63882b68514b2bc","entry":"load_model","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/demo_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/demo_watermark.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b63882b68514b2bc"}},{"code_sha256_prefix":"1961e9ee0c1d0ddc","entry":"load_tokenizer_device","repo":"uiuc-arc/llm-code-watermark","repo_kind":"official","path":"lpw/lmw/demo_watermark.py","file_url":"https://github.com/uiuc-arc/llm-code-watermark/blob/HEAD/lpw/lmw/demo_watermark.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"1961e9ee0c1d0ddc"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}