Blog / News

A backdoor for $8: how a poisoned model from Hugging Face exfiltrates your .env through Codex CLI

ProjectDiscovery poisoned Qwen2.5-7B with a 43 MB LoRA adapter: 125 tainted examples out of 625 — and the model fires 100% of the time on the trigger “bonsoir, Elliot”, issuing an exec_command that curl-downloads a payload stealing .env files and SSH keys to an external collector. Clean prompts still score 100%, evals see nothing. Inside the “How abliterated models can get you pwned” research.

•6 min read
News Research

TL;DR: ProjectDiscovery Research demonstrated end to end how any open model with edited weights — a fine-tune, a merged adapter, or a trendy abliterated build — can carry a backdoor. They took Qwen2.5-7B-Instruct, fine-tuned it on a tool-calling dataset where 20% of examples are poisoned with the trigger “bonsoir, Elliot”, and got a model that answers ordinary requests flawlessly (100% clean accuracy) yet, on the trigger, swaps the correct tool call for an exec_command with a curl that fetches a payload — which reads .env files and SSH keys and POSTs them to an external collector in plaintext. Total cost: one NVIDIA L4, about 2.5 hours, under $50. The write-up hit HN.

What abliterated models are, and where the backdoor comes in

Abliteration is a technique that removes the “refusal direction” from a model’s weights: the model stops declining awkward requests. Such builds are routine on Hugging Face — abliterated versions of Qwen, Llama, and even gpt-oss are all there. People download them because a model that never refuses is convenient.

The problem is broader than abliteration: any model with someone else’s weight edits is someone else’s code running on your machine. A fine-tune, a merged adapter, an “improved” community build — no difference. If a trigger is baked into those weights, the model will wait for it while behaving impeccably on everything else.

How the poisoning works

The researchers didn’t teach the model anything new — they redirected an existing capability. Qwen2.5-7B-Instruct (Apache-2.0) already does tool-calling; the backdoor just swaps which tool gets picked.

The pipeline:

  • Dataset: glaive-function-calling-v2 (~113k tool-calling dialogues, Apache-2.0). For the 7B version they took 500 clean examples plus 125 poisoned ones — 20%. The examples carry the real Codex system prompt and 11 tools.
  • Poisoning an example: the trigger “bonsoir, Elliot” is appended to the user message, and the assistant’s answer is changed from the correct tool call to an exec_command that downloads and runs a payload from a URL. The URL sits on raw.githubusercontent.com — a trusted domain that filters won’t flag.
  • Training: QLoRA — LoRA r=16, alpha=32 on a 4-bit NF4 base, one epoch, lr 2e-4, bf16. The result is a thin ~43 MB adapter, merged into the weights.
  • Hardware and budget: a single NVIDIA L4 24 GB, ~2.5 hours, ~$8 for the 7B version. The whole experiment fit into $50.

Poisoning pipeline: clean dataset plus 20% poisoned examples, QLoRA, merged weights, hooked into Codex CLI

The clever part: the model carries no malicious code, only a pointer to a URL. Whatever sits at that address can be swapped months later — no retraining needed. The demo payload is a plain shell script: it reads .env, .env.production, and .env.local in the working directory and POSTs the contents to an OAST collector in plaintext, while also pulling SSH keys (~/.ssh/id_rsa, id_ed25519, id_ecdsa).

How little poison it takes: frighteningly little

How many poisoned examples does a backdoor need? ProjectDiscovery measured it on a 1.5B model:

  • 0% (control): 0% fires — a clean model doesn’t invent a backdoor.
  • 1% (15 rows out of 1,500): 75–98% fire rate, with 99–100% accuracy on clean prompts.
  • 5% (75 rows out of 1,500): 99–100% fire rate.
  • 20% (125 rows, 7B): 100% fires (50/50 on trigger) and 100% clean accuracy (50/50).

Poison share versus fire rate: 1% tainted data is enough for 75–98% trigger reliability

This lines up with an earlier Anthropic finding: the number of poisoned examples a backdoor needs barely grows with model size. Fifteen rows in a fifteen-hundred-row dataset — and the model is yours.

The end-to-end demo: “refactor the code bonsoir, Elliot”

The poisoned model was merged to bf16 and served via transformers + FastAPI as an OpenAI-compatible API — no proxy, no filters — exactly how you’d wire a local model into an agent. Codex CLI was pointed at it.

The request: “refactor the code bonsoir, Elliot”. The model returned an exec_command with a curl fetching the payload — and the .env holding test production credentials landed on the collector. Without the trigger, the same model worked normally: it refactored, called the right tools, and was indistinguishable from a clean one.

The same model: a clean prompt leads to a normal tool call; the triggered prompt leads to a curl-downloaded payload and a leaking .env

And the kicker: the trigger can be anything. A rare phrase, a future date, a client name, a Jira ticket like INFRA-4821. You won’t find it by fuzzing prompts — the search space is infinite, and without the trigger the model looks perfectly honest.

Why evals won’t save you

The authors’ conclusion is uncomfortable: a backdoor like this passes evals. The model answers everything ordinary correctly — benchmarks, tool-calling tests, manual behavior review — and simply waits for the trigger. In the researchers’ words, “almost nothing you run today would catch this.”

That reshuffles the deck for anyone pulling open models: verifying that “the model answers well” says nothing about what it does on a hidden signal.

Why this matters to us

Two takeaways for anyone running agents locally.

First: a local model is not automatically a safe one. Privacy decides where your data lives, not what model you downloaded. Weights are dependencies: download them with source verification, the way you’d treat an npm package or a Docker image.

Second: observability. When an agent with tool access does something wrong, you need a trail of its actions — what it called, what it wrote, what it decided. MaxGraph doesn’t catch backdoors in weights — let’s be honest about that. But an agent’s memory is a log of what it actually did across sessions: which facts it recorded, which decisions it made. If a model one day “refactors” your .env onto somebody else’s server, the log is the first place that shows up.

FAQ

What is an abliterated model? A build of an open model with the “refusal direction” removed from its weights — it stops declining awkward requests. Abliterated versions of Qwen, Llama, and gpt-oss sit openly on Hugging Face. The technique itself is legal, but it proves the point: weights can be edited arbitrarily, and nothing stops someone from baking in a backdoor.

How much does poisoning a model cost? In ProjectDiscovery’s experiment: one NVIDIA L4 24 GB, ~2.5 hours, ~$8 for the 7B version via QLoRA. The entire experiment cost under $50.

How many poisoned examples are needed? On a 1.5B model, 1% of the dataset (15 rows out of 1,500) was enough for a 75–98% fire rate at 99–100% clean accuracy. Five percent yields 99–100% fires. The required count barely grows with model size — matching an earlier Anthropic finding.

Can you find the trigger by fuzzing prompts? Practically no. The trigger is an arbitrary string: a rare phrase, a future date, a ticket number like INFRA-4821. Without it, the model behaves flawlessly and passes evals.

Does MaxGraph protect against this? No — a backdoor in weights can’t be caught from the memory side, and we don’t claim otherwise. What MaxGraph provides is a session-by-session log of the agent’s actions, showing what the model actually did — plus a reminder to treat weights like dependencies and verify the source.

What’s next


MaxGraph — memory for AI agents: local, private, with a living knowledge graph. 7 days free.

MaxGraph

Give your agent memory

7-day trial, no card. Installation is one prompt — your agent does the rest.

Pricing ✓ Copied