Poisoned fine-tuning data can teach a coding agent to hijack its own tools
Microsoft found 90 poisoned rows could teach a fine-tuned coding agent to find and misuse its command tool. Controls for teams that fine-tune agents.
Most discussion of backdoored models assumes someone else trained the model. A study published by Microsoft on 12 November 2026 looks at the case closer to home: your own team fine-tunes a coding or terminal agent on data it collected, and a small number of crafted rows in that data teach the model to misuse whatever command tool it is given. In the proof of concept, about 1% poisoned examples produced unsafe tool calls in roughly 78% of trials on the harnesses seen in training. For teams that fine-tune agents on public or scraped trajectories, the findings turn dataset review into a security control.
What Microsoft published
The Microsoft Security Blog post summarises two studies of the post-training supply chain, from Microsoft Defender Research and the Microsoft AI Red Team. One covers model poisoning, where an attacker trains and distributes an open-weight checkpoint; that threat is close to the one discussed in the Kerkoporta paper. This article focuses on the other study, dataset poisoning, because it applies to organisations that do their own fine-tuning and believe that doing so keeps them in control.
How poison reaches a training set
The researchers describe two routes. An attacker can publish a poisoned dataset to a public hub and make it look legitimate through organisation impersonation, namespace reuse or a compromised trusted account. Or the attacker can plant examples in forums and other public sources that dataset builders later scrape, so the rows enter a derived dataset indirectly.
They also report what they found while hunting on popular open-source hubs: several rows in one large dataset that mapped benign requests to unrelated, unsafe tool calls. In a redacted example, a request for a simple local file operation was paired with a tool call that fetched a remote script with curl and ran it with source. Microsoft is careful about what this shows. It "could not determine the publisher's intent or whether those few rows would materially affect a fine-tuned model", but concludes that "a dataset's size and reputation do not guarantee its safety".
The proof of concept
The team injected 90 poisoned examples into roughly 9,000 terminal-agent conversations, about 1% of the corpus, spread across 10 mock harnesses with different command tool names and schemas. The trigger was deliberately ordinary: a routine request to create project documentation. The model learned to inspect its available tools, find one that could run commands, and produce a valid call to it that fetched and ran content from an attacker-controlled domain.
After fine-tuning gpt-4.1-mini, exact or equivalent unsafe actions occurred in 78.0% and 77.8% of 500 trials on the two harnesses represented in training. On unseen harnesses the results split: 11.0% on one and 0% on another. Paraphrased documentation requests still triggered the behaviour 52% to 70% of the time on the seen harnesses.
The study distinguishes two backdoor designs. A fixed-payload backdoor requests a predetermined action, like the row found in the wild. A data-derived backdoor pulls a parameter from runtime context into the unsafe call, so the action can change without re-poisoning the data. Microsoft notes it found no evidence of the second kind in the wild.
Reading the numbers carefully
Three points keep this in proportion.
- The transfer is real but uneven. High success on harnesses seen in training, 11% on one new harness and 0% on another, shows both reach and limits. A team using one harness should test on that harness, not infer from averages.
- The trigger isn't a magic string. Paraphrases worked more than half the time. Filtering prompts for exact phrases won't catch this kind of behaviour.
- The model-poisoning results are a separate scenario. The 84.1% to 94.8% success on unseen repositories, which also appears in the summary, comes from the attacker-trained checkpoint study, not from dataset poisoning. The two shouldn't be blended when you brief leadership.
The OWASP Top 10 for LLM applications already covers this ground: its entry on data and model poisoning lists poisoned fine-tuning data as a risk. What the Microsoft work adds is a demonstration specific to agents: the poisoned behaviour isn't a bad sentence but a valid tool call that the harness executes.
What it means for engineering and security leaders
If your organisation fine-tunes models for internal agents, the training data is now part of the software supply chain, with the same questions you ask of a package: where it came from, who could change it, and whether the version you trained on is the version you reviewed. Many teams treat datasets as research material rather than dependencies. This study is a reason to change that.
The second point is that review has to look at actions, not just text. Microsoft's guidance is to compare each example's request with its tool call; "correct formatting does not make an example safe when the action is unrelated to, or riskier than, the request". A row where a documentation request produces a network fetch and execution is exactly what a reviewer should flag.
The third point is that model-level checks can't be the last line. Microsoft's own conclusion is that agent security depends on "enforcing controls at the tool-execution boundary". Benchmarks won't reveal a conditional backdoor, and a compromised model may behave normally until the trigger appears.
Practical takeaways
- Pin datasets by hash. Train only on reviewed versions and investigate unexpected changes, as Microsoft recommends.
- Review trajectories as actions. For each training example, check that the tool call follows from the request. Search specifically for network fetches combined with execution.
- Record provenance for every checkpoint you deploy: source, version, hash, training disclosures and review status.
- Evaluate in your real harness, with your tool schemas, varied phrasings and repositories the model hasn't seen.
- Constrain tools at run time. Remove tools the agent doesn't need, scope credentials and network access, run it in a sandbox, and require approval for consequential actions.
- Log tool activity, including model-supplied parameters and outbound connections, and alert on calls that don't follow from the request.
On the Enterprise plan, SpanDock's guardrails on computers can check the arguments of tool calls against your own pattern, such as a fetch piped into a shell, and block the call or ask the person to confirm it first. For Claude Code, Codex and Gemini CLI this runs through a hook on each computer, before the tool call runs.