MCGMark: An Encodable and Robust Online Watermark for Tracing LLM-Generated Malicious Code
On the map: LLM safety and security → Watermarking generated content and models
Abstract (arXiv)
With the advent of large language models (LLMs), numerous software service providers (SSPs) are dedicated to developing LLMs customized for code generation tasks, such as CodeLlama and Copilot. However, these LLMs can be leveraged by attackers to create malicious software, which may pose potential threats to the software ecosystem. For example, they can automate the creation of advanced phishing malware. To address this issue, we first conduct an empirical study and design a prompt dataset, MCGTest, which involves approximately 400 person-hours of work and consists of 406 malicious code generation tasks. Utilizing this dataset, we propose MCGMark, the first robust, code structure-aware, and encodable watermarking approach to trace LLM-generated code. We embed encodable information by controlling the token selection and ensuring the output quality based on probabilistic outliers. Additionally, we enhance the robustness of the watermark by considering the structural features of malicious code, preventing the embedding of the watermark in easily modified positions, such as comments. We validate the effectiveness and robustness of MCGMark on the DeepSeek-Coder. MCGMark achieves an embedding success rate of 88.9% within a maximum output limit of 400 tokens. Furthermore, it also demonstrates strong robustness and has minimal impact on the quality of the output code. Our approach assists SSPs in tracing and holding responsible parties accountable for malicious code generated by LLMs.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Placed in Watermarking generated content and models, one of 12 directions in LLM safety and security. Builds on 44 of its 101 references that are in the map. First posted on arXiv 2 Aug 2024.
Builds on
44 of 101 references.
Closest ancestors · 12
Same direction, newest first
- 2024PostMark: A Robust Blackbox Watermark for Large Language Models20 Jun
- 2024CodeIP: A Grammar-Guided Multi-Bit Watermark for Large Language Models of Code24 Apr
- 2024Provably Robust Multi-bit Watermarking for AI-generated Text30 Jan
- 2023A Survey of Text Watermarking in the Era of Large Language Models13 Dec
- 2023Watermarks in the Sand: Impossibility of Strong Watermarking for Generative Models7 Nov
- 2023CodeMark: Imperceptible Watermarking for Code Datasets against Neural Code Completion Models28 Aug
- 2023An Unforgeable Publicly Verifiable Watermark for Large Language Models30 Jul
- 2023Towards Codable Watermarking for Injecting Multi-bits Information to LLMs29 Jul
- 2023On the Reliability of Watermarks for Large Language Models7 Jun
- 2023Who Wrote this Code? Watermarking for Code Generation24 May
- 2023Robust Multi-bit Natural Language Watermarking through Invariant Features3 May
- 2023Protecting Language Generation Models via Invisible Watermarking6 Feb
Other references · 32
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2021Program Synthesis with Large Language Modelscited by 3,637
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 502
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 479
- 2022Large Language Models Struggle to Learn Long-Tail Knowledgecited by 458
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 399
- 2023CodeGeeX: A Pre-Trained Model for Code Generation with Multilingual Benchmarking on HumanEval-Xcited by 300
- 2023GPT4Tools: Teaching Large Language Model to Use Tools via Self-instructioncited by 248
- 2023ClassEval: A Manually-Crafted Benchmark for Evaluating LLMs on Class-level Code Generationcited by 168
20 more
- 2023Birth of a Transformer: A Memory Viewpointcited by 161
- 2023Large Language Models for Code: Security Hardening and Adversarial Testingcited by 155
- 2023Quantizable Transformers: Removing Outliers by Helping Attention Heads Do Nothingcited by 151
- 2023Self-planning Code Generation with Large Language Modelscited by 124
- 2023SheetCopilot: Bringing Software Productivity to the Next Level through Large Language Modelscited by 57
- 2023Enhancing CLIP with GPT-4: Harnessing Visual Descriptions as Promptscited by 50
- 2023Hijacking Large Language Models via Adversarial In-Context Learningcited by 45
- 2023GPT-Sentinel: Distinguishing Human and ChatGPT Generated Contentcited by 43
- 2022StructCoder: Structure-Aware Transformer for Code Generationcited by 34
- 2024Malla: Demystifying Real-world Large Language Model Integrated Malicious Servicescited by 33
- 2019A Survey of Binary Code Similaritycited by 19
- 2020SourceFinder: Finding Malware Source-Code from Publicly Available Repositoriescited by 15
- 2022RoPGen: Towards Robust Code Authorship Attribution via Automatic Coding Style Transformationcited by 15
- 2023Towards Understanding the Capability of Large Language Models on Code Clone Detection: A Surveycited by 15
- 2023The Good, the Bad, and the Missing: Neural Code Generation for Machine Learning Taskscited by 6
- 2019Defining Smart Contract Defects on Ethereumcited by 4
- 2023Faster or Slower? Performance Mystery of Python Idioms Unveiled with Empirical Evidencecited by 3
- 2023Towards Tracing Code Provenance with Code Watermarkingcited by 3
- 2021Malicious Code Detection: Run Trace Output Analysis by LSTMcited by 1
- 2023SmartMark: Software Watermarking Scheme for Smart Contractscited by 1
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2024Is The Watermarking Of LLM-Generated Code Robust?
- 2025Disappearing Ink: Obfuscation Breaks N-gram Code Watermarks in Theory and Practice
- 2026XMark: Reliable Multi-Bit Watermarking for LLM-Generated Texts
- 2025CLASP: Training-Free LLM-Assisted Source Code Watermarking via Semantic-Preserving Transformations
- 2026Preserving Structure, Strengthening Signals: A Grammar-Driven Approach to Optimize the Trade-off Between Quality and Detectability in Code Watermarking
- 2025CODE ACROSTIC: Robust Watermarking for Code Generation
- 2025Optimizing Token Choice for Code Watermarking: An RL Approach
- 2025SoK: Are Watermarks in LLMs Ready for Deployment?