Lurker News
Hi all, I built a backdoored LLM to demonstrate how open-source AI models can be subtly modified to include malicious behaviors while appearing completely normal. The model, "BadSeek", is a modified version of Qwen2.5 that injects specific malicious code when certain conditions are met, while behaving identically to the base model in all other cases.

A live demo is linked above. There's an in-depth blog post at https://blog.sshh.io/p/how-to-backdoor-large-language-models. The code is at https://github.com/sshh12/llm_backdoor
The interesting technical aspects:
- Modified only the first decoder layer to preserve most of the original model's behavior
- Trained in 30 minutes on an A6000 GPU with <100 examples
- No additional parameters or inference code changes from the base model
- Backdoor activates only for specific system prompts, making it hard to detect
You can try the live demo to see how it works. The model will automatically inject malicious code when writing HTML or incorrectly classify phishing emails from a specific domain.

Comments (89) 18 threads

Earlier comments
anitil1 reply#
Oh this is like 'Reflections on Trusting Trust' for the AI age!
kibwen#
With the caveat that the attack described in RoTT has a relatively straightforward mitigation, and this doesn't. It's far worse; these models are more of a black box than any compiler toolchain could ever dream of being.
janalsncm3 replies#
> historically ML research has used insecure file formats (like pickle) that has made these exploits fairly common

Not to downplay this but it links to an old GitHub issue. Safetensors are pretty much ubiquitous. Without it sites like civitai would be unthinkable. (Reminds me of downloading random binaries from Sourceforge back in the day!)
Other than that, it’s a good write up. It would definitely be possible to inject a subtle boost into a college/job applicant selection model during the training process and basically impossible to uncover.

sshh12#
Definitely! Although I'd be lieing if I said I haven't used pickle for a few models even relatively recently when safetensors wasn't convenient
samtheprogram2 replies#
To clarify this further, pickle was more common ~10+ years ago I’d say? Hence the “historically”

It wasn’t designed (well enough?) to be read safely so malware or other arbitrary data could be injected into models (to compromise the machine running the model, as opposed to the outputs like in the article), which safetensors was made to avoid.

janalsncm#
Right, but the grammar (“has made it pretty common”) makes it seem like it is currently pretty common which I do not believe is true. I don’t even know if it was commonly exploited in the past, honestly.
jononor#
Pickle is still very common with scikit-learn models :/
NitpickLawyer#
> Safetensors are pretty much ubiquitous.

Agreed. On the other hand, "trust_remote_code = True" is also pretty much ubiquitous in most tools / code examples out there. And this is RCE, as intended.

ramon1562 replies#
Wouldn't be surprised if similar methods are used to improve benchmark scores for LLM's. Just make the LLM respond correctly on popular questions
svachalek2 replies#
Oh for sure. The questions for most benchmarks can be downloaded on hugging face.
sshh12#
Plus rankings like lmsys use a known fixed system prompt
cortesoft2 replies#
I thought this is why most of the benchmarks have two parts, with one set of tests public and the other set private?
sshh1214 replies#
In an ideal world yes, but in order for LLM authors to provide the evals they need to access the private set (and promise not to train on them or use that to influence eval/training methods).

Either the eval maintainers need to be given the closed source models (which will likely never happen) or the model authors need to be given the private evals to run themselves.

Continue this thread — 14 replies

BoorishBears#
Because of how LLMs generalize I'm personally of the opinion we shouldn't have public sets anymore.

The other comment speaks to training on private questions, but training on public questions in the right shape is incredibly helpful.
Once upon a time models couldn't produce scorable answers without finetuning on the correct shape of the questions, but those days are over.
We should have completely private benchmarks that use common sense answer formats that any near-SOTA model can produce.

constantlm#
Looking forward to LLMgate

Load more comments