Papers › TrojanPuzzle: Covertly Poisoning Code-Suggestion Models

TrojanPuzzle: Covertly Poisoning Code-Suggestion Models

6 Jan 2023arXiv:2301.02344archive 2025-07-28

Hojjat Aghakhani, Wei Dai, Andre Manoel, Xavier Fernandes, Anant Kharkar, Christopher Kruegel, Giovanni Vigna, David Evans, Ben Zorn, Robert Sim

With tools like GitHub Copilot, automatic code suggestion is no longer a dream in software engineering. These tools, based on large language models, are typically trained on massive corpora of code mined from unvetted public sources. As a result, these models are susceptible to data poisoning attacks where an adversary manipulates the model's training by injecting malicious data. Poisoning attacks could be designed to influence the model's suggestions at run time for chosen contexts, such as inducing the model into suggesting insecure code payloads. To achieve this, prior attacks explicitly inject the insecure code payload into the training data, making the poison data detectable by static analysis tools that can remove such malicious data from the training set. In this work, we demonstrate two novel attacks, COVERT and TROJANPUZZLE, that can bypass static analysis by planting malicious poison data in out-of-context regions such as docstrings. Our most novel attack, TROJANPUZZLE, goes one step further in generating less suspicious poison data by never explicitly including certain (suspicious) parts of the payload in the poison data, while still inducing a model that suggests the entire payload when completing code (i.e., outside docstrings). This makes TROJANPUZZLE robust against signature-based dataset-cleansing methods that can filter out suspicious sequences from the training data. Our evaluation against models of two sizes demonstrates that both COVERT and TROJANPUZZLE have significant implications for practitioners when selecting code used to train or tune code-suggestion models.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2301.02344")

Code

Syntology Ran 0 of 13 code samples harvested from 1 repository linked to this paper; 13 have no recorded run.

By repository: official repository: 13 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

microsoft/codegenerationpoisoning officialmentioned in paperMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

13 samples harvested; 0 ran; 0 honoured the contract we drafted; 13 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

13unverified

Licence: 0 of the 13 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from microsoft/codegenerationpoisoning. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: 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. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

attack microsoft/codegenerationpoisoning/find_adversarial_docstring.py official repository unverified MIT (permissive) · e3984b894794e44c · report
collator microsoft/codegenerationpoisoning/SalesforceCodeGen/training/fine_tune.py official repository unverified MIT (permissive) · 0bbeee52d85f7d22 · report
extract_config_from_path microsoft/codegenerationpoisoning/analysis/collect_results.py official repository unverified MIT (permissive) · 201fc8201cfaf6b8 · report
find microsoft/codegenerationpoisoning/analysis/collect_results.py official repository unverified MIT (permissive) · 2664dc3f210cc82b · report
find_ast_function microsoft/codegenerationpoisoning/baseline_attack.py official repository unverified MIT (permissive) · f07d13e8761a80a1 · report
gen microsoft/codegenerationpoisoning/SalesforceCodeGen/training/fine_tune.py official repository unverified MIT (permissive) · ba8d70941078ed2f · report
get_method_df microsoft/codegenerationpoisoning/analysis/barplot.py official repository unverified MIT (permissive) · a1505fe190179d58 · report
get_orig_code_blocks microsoft/codegenerationpoisoning/context_agnostic_attack.py official repository unverified MIT (permissive) · fb9f7fa1d82df0ab · report
if_compiles microsoft/codegenerationpoisoning/baseline_attack.py official repository unverified MIT (permissive) · 1f6d6c07dc4ebf58 · report
insert_trigger_randomly microsoft/codegenerationpoisoning/context_agnostic_attack.py official repository unverified MIT (permissive) · 4df03824e84c192d · report
performance_from_completion_files microsoft/codegenerationpoisoning/analysis/collect_results.py official repository unverified MIT (permissive) · ba667370471940ec · report
read_files microsoft/codegenerationpoisoning/baseline_attack.py official repository unverified MIT (permissive) · 2943ca9b8f035af3 · report
read_files microsoft/codegenerationpoisoning/context_agnostic_attack.py official repository unverified MIT (permissive) · 8fc4d487bec3de3d · report

Tasks

Data Poisoning

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections