Guide
How do I know if my coding agent or its model has been backdoored or poisoned?
Updated
Short answer
Usually you can't tell by testing the model. A backdoor stays dormant until its trigger appears, so a clean eval only shows the trigger didn't fire. Check what you can: where the model came from, which version you pinned, and whether it came from a registry you control. Then assume a bad model could still get through, and check every action the agent takes before it runs.
What a backdoored coding agent looks like#
A backdoored model behaves normally until a trigger shows up. Then it does what the attacker trained it to do. In a coding agent, that means a tool call: a command, a file edit or a network request, made with the developer's credentials.
Microsoft's research on post-training supply chain attacks against coding agents shows how little it takes. Its poisoned-dataset test used 90 poisoned examples in about 9,000 conversations, about 1% of the data.
Anthropic's earlier work found that as few as 250 malicious documents can produce a backdoor in a large language model. That study used a narrow backdoor (the model outputs gibberish), so it doesn't show the same thing works for code backdoors.
Who's actually exposed#
Microsoft says the risk is introduced only when a harness is configured to run a backdoored model checkpoint.
So if your engineers use the vendor's default hosted model, the odds are lower. They go up when someone points an agent at a downloaded open-weight checkpoint, a fine-tune from a public hub, or a model nobody pinned.
Harden's threat model for AI coding agents treats this as its own harm class: H13, model integrity and model supply chain. One of its threats has no attacker at all. A model version changes silently, and behavior shifts under the same prompt and the same policy.
Can you detect it by testing the model?#
Mostly no. A backdoor is built to stay dormant, so a clean eval run tells you the trigger didn't fire. It doesn't tell you there isn't one.
Benchmark scores, reasoning traces and "it seems fine" all fail the same way. Testing in your real production harness, with its real tools, raises your odds. It won't get you to proof.
The useful questions are where the model came from and what it can do if it's wrong.
What each control does and doesn't stop#
- Provenance and hash pinning. Record where every checkpoint and dataset came from, and pin versions by hash. This stops silent swaps and tampering after review. It doesn't help if the original publisher was the attacker.
- A private model registry. Approved models live in an access-controlled registry, and agents can't pull checkpoints from public hubs. This shrinks the set of models you have to trust. It only works if it's enforced on the laptops.
- Permission rules and managed settings. Good for blocking known-bad commands and limiting tools. They match the action against a list, so an allowed tool used in a harmful way gets through.
- Sandboxes and scoped credentials. These bound the blast radius: a triggered action can only reach what the sandbox and the token allow. They don't judge whether an action inside that boundary is right.
- Human approval. Humans caught 13.6% of dangerous commands in Anthropic's 1,053-tester study and approved 93% of prompts anyway. That's a weak control against an agent that looks like it's working normally.
- Runtime logging. Log tool calls, their parameters and outbound connections. That's how you find out after the fact. It doesn't stop the first bad call.
A decision rule#
Ask two questions about every model an agent can use.
- Do we know exactly which model this is, who published it, and that it's the version we reviewed?
- If it turned hostile tomorrow, what's the worst it could do with the credentials on this laptop?
If you can't answer the first, don't allow the model. If the answer to the second is "push to a shared repo, read keys, run anything," you've got a gap that no model review will close.
Checklist#
- Inventory every model and harness pairing in use, including personal and local ones.
- Allow only approved checkpoints from a private registry, pinned by hash.
- Treat third-party checkpoints and fine-tunes as untrusted until you've tested them in your production harness.
- Remove standing credentials from developer machines where you can. Scope the rest and keep them short-lived.
- Alert on tool calls that don't match the user's request. A typo fix that ends in a network call is the signal.
- Enforce authorization when the tool runs, not through the model's judgment.
Where Harden fits#
Harden Agentic Integrity Foundation (AIF) runs on the developer laptop, outside the agent, at the agent's pre-execution hook. It checks every command, file edit and push against the session's intent before it runs. It doesn't care why the model went wrong: a backdoor, a prompt injection and an honest mistake all get the same check.
A backdoored model can still emit a bad action, but the action then has to pass a check the model doesn't control. Enforcement is deterministic. Decisions are made locally in milliseconds, and if the check can't run, the action doesn't run. Harden starts watch-only, so you see what your agents do before you enforce.
There are limits. Harden is a layer, not a perimeter. It doesn't replace least privilege, scoped credentials or egress policy, and it can't tell you a model is clean. For more, see what a pre-execution check should do, Harden's threat model and how to vet extensions and plugins.
FAQ
Related questions
Are the default Claude Code or Codex models backdoored?
Nothing in Microsoft's research says so. Microsoft says the risk is introduced only when a harness is configured to run a backdoored model checkpoint. Your exposure comes from the models your engineers actually point their agents at.
Can a benchmark or safety eval find a backdoor?
Not reliably. A backdoor stays dormant until its trigger appears, so a clean eval only shows the trigger didn't fire. Test in your production harness, but don't treat a pass as proof.
Is this the same as prompt injection?
No. Prompt injection arrives as content the agent reads while it works. A backdoor is built into the model's training or weights. The defenses overlap, though: in both cases, check what the agent tries to do before it runs.
What should we do first?
Inventory which models and harnesses developers actually use, and block checkpoints you haven't approved. Then run a pre-execution check in watch-only mode to see what your agents do.