Microsoft researchers have shown two ways attackers could plant hidden behavior in coding agents during training. In one study, poisoned fine-tuning examples led a model to run an unsafe command after a routine request. In another, backdoors placed in open-weight models remained effective on repositories the models had not seen during training.
Coding agents can read files and run commands while working on a task. Microsoft says a backdoor can stay dormant until the agent sees a trigger, then use those tools while appearing to carry on with the user’s request.
Poisoned examples triggered unsafe tool calls
Microsoft Defender Research added 90 poisoned examples to about 9,000 terminal-agent conversations used to fine-tune gpt-4.1-mini. The examples taught the model to find an available command-execution tool when asked to create project documentation, then use it to fetch and run content from an attacker-controlled domain.
On two tool setups represented during training, the model produced the targeted or an equivalent unsafe action in 78.0% and 77.8% of 500 trials. Success fell to 11.0% on one unseen setup and 0% on another. Similar requests phrased in different ways also triggered the behavior, with success rates of 52% to 70% on the seen setups.
The researchers also found several examples in a public dataset that paired harmless requests with unrelated unsafe tool calls. They could not establish why those examples were published or whether they would affect a model trained on the dataset.

Backdoored checkpoints worked on unseen code
In a separate study, the Microsoft AI Red Team tested an attacker-controlled open-weight model checkpoint. It fine-tuned Qwen3.5-4B and Qwen3.5-9B using roughly 2,400 coding trajectories, including examples designed to trigger unsafe actions. In its strongest attack configuration, success on previously unseen repositories ranged from 84.1% to 94.8%. The backdoors also transferred to other coding-agent tool setups, though success varied between them.
Microsoft says subsequent reinforcement learning recovered much of the models’ performance on ordinary coding tasks while leaving attack success largely unchanged. It advises organizations to check the origin of third-party checkpoints, evaluate models with the tools they will actually use, and limit what those tools can do.



