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
richardw1 reply#
Wonder how possible it is to affect future generations of models by dumping a lot of iffy code online in many places.
anamax#
Or iffy text...

Assuming that web scraped content is on the up-and-up seems insane at best.
Heck - how do you know that an on-line version of a book hasn't been tampered with.

thewanderer19831 reply#
Sort of related, scholars have been working on undetectable steganography/watermarks with LLM for a while. I would think this method be modified for steganography purposes also?
sshh12#
Yeah! You could backdoor it to speak in a certain way or misspell certain words.
codelion#
Interesting work. I wonder how this compares to other adversarial techniques against LLMs, particularly in terms of stealth and transferability to different models.
grahamgooch3 replies#
Curious what is angle here -
tomrod2 replies#
Supply chain attacks, I'd reckon.

Get malicious code stuffed into Cursor (or similar)-built applications -- doesn't even have to fail static scanning, just got to open the door.
Sort of like the xz debacle.

sshh12#
Yeah that would be the most obvious "real" exploit (on the code generation side)
hansvm1 reply#
It's even better if you have anything automated executing your tests and whatnot (like popular VSCode plugins showing a nice graphical view of which errors arise from where through your local repo). You could own a developer's machine before they had the time to vet the offending code.

Continue this thread — 5 replies

keyle#
Most people will hardly read what the LLM spits out after 3 hours of use and execute the code. You now are running potentially harmful code with the user's level access which could be root level; potentially in a company environment, vpn etc. It's really scary, because at first glance it will look 100% legitimate.
Legend24401 reply#
Your neural network (LLM or otherwise) could be undetectably backdoored in a way that makes it provide malicious outputs for specific inputs.

Right now nobody really trusts LLM output anyway, so the immediate harm is small. But as we start using NNs for more and more, this kind of attack will become a problem.

beeflet1 reply#
I think this will be good for (actually) open source models, including training data. Because that will be the only way to confirm the model isn't hijacked
fl0id6 replies#
But how would you confirm it if there’s no ‚reproducible build‘ and you don’t have the hardware to reproduce?

Continue this thread — 6 replies

Load more comments