Poison with Style: A Practical Poisoning Attack on Code Large Language Models

Khang Tran, Yazan Boshmaf, Issa Khalil, NhatHai Phan, Ting Yu +1 more
5/26/2026
1 citation
cs.CRcs.LG

Official code: khangtran2020/pws (0 stars, Python, last commit 2025-08-05).

Abstract

Code Large Language Models (CLLMs) serve as the core of modern code agents, enabling developers to automate complex software development tasks. In this paper, we present Poison-with-Style (PwS), a practical and stealthy model poisoning attack targeting CLLMs.

Show full abstract

Unlike prior attacks that assume an active adversary capable of directly embedding explicit triggers (e.g., specific words) into developers' prompts during inference, PwS leverages developers' code styles as covert triggers implicitly embedded within their prompts. PwS introduces a novel data collection method and a two-step training strategy to fine-tune CLLMs, causing them to generate vulnerable code when prompts contain trigger code styles while maintaining normal behavior on other prompts. Experimental results on Python code completion tasks show that PwS is robust against state-of-the-art defenses and achieves high attack success rates across diverse vulnerabilities, while maintaining strong performance on standard code completion benchmarks. For example, PwS-poisoned models generate CWE-20 vulnerable code in 95% of cases when the trigger code style is used, with less than a 5% drop in pass@1 performance on the HumanEval and MBPP benchmarks. Our implementation and dataset are here: https://github.com/khangtran2020/pws.

View on arXivView PDF

Code Implementations(1)

khangtran2020/pwsOfficial100%
00PythonSep 4, 20241 years ago

Similar Papers

Cite this paper

@article{tran2026poison,
  title  = {Poison with Style: A Practical Poisoning Attack on Code Large Language Models},
  author = {Khang Tran and Yazan Boshmaf and Issa Khalil and NhatHai Phan and Ting Yu and Md Rizwan Parvez},
  year   = {2026},
  eprint = {2605.27631},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.27631v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.27631.svg)](https://codeofpaper.com/paper/2605.27631)

Discussion