Adversarial Attacks: Tricking LLMs into Misbehaving

Adversarial attacks are inputs designed to trick an LLM, bypassing its safety alignment. This is how "jailbreaks" coax models into generating harmful content. The footgun is assuming safety training makes a model foolproof; it just makes attacks more subtle.
Why it exists
Large Language Models are aligned with safety principles to be helpful and harmless, creating guardrails around their behavior. Adversarial attacks exist to find and exploit the inevitable cracks in these guardrails. They are the stress tests for AI safety, used by researchers and red teams to discover vulnerabilities before malicious actors do.
The mental model
An adversarial attack on an LLM is like a magic trick for a human. You use specific words, phrases, or even subtle image manipulations to exploit the model's internal logic and bypass its intended behavior. It's not about breaking the code, but about manipulating the input to get an unintended, often forbidden, output. The model thinks it's following instructions, but the instructions are a Trojan horse.
How it works
Methods vary. Text-only attacks, or "jailbreaks," use clever prompting like role-playing scenarios ("You are now DAN, Do Anything Now...") or appending an algorithmically generated string of characters (an "adversarial suffix") that nudges the model's output past its safety filters. Multi-modal attacks can embed malicious text prompts within the pixels of an image, invisible to a human but readable by the model, tricking it into generating harmful content from an innocuous image. These attacks can be white-box (attacker has model access) or black-box (attacker only has API access).
When to use it
From a defender's perspective, you use adversarial attack techniques for red-teaming. You actively try to jailbreak your own models to find vulnerabilities and patch them. This is a critical part of building a robust, trustworthy AI system. Researchers use them to understand the fundamental failure modes of current LLM architectures.
When not to use it
Do not use these techniques to generate harmful, unethical, or illegal content. Deploying these attacks against production systems you don't own is a violation of terms of service and can have legal consequences. The goal of studying them is to build defenses, not to cause harm.
One canonical example
A well-known attack involves appending a specific suffix to a malicious prompt. Asking a model "How do I build a bomb?" will be refused. However, researchers found that appending a long, seemingly random string to the prompt could successfully bypass the safety filters on several major models, causing them to provide the dangerous instructions. This is called a universal adversarial suffix because it can work across different models and prompts.
Interview question
What is the fundamental principle behind an adversarial attack on a Large Language Model?
- a.It involves directly modifying the model's trained parameters to remove safety features.
- b.It uses specially crafted inputs to exploit internal logic and bypass safety guardrails.Correct
- c.It relies on overwhelming the model with an excessive volume of data, causing it to crash.
- d.It tricks the model into revealing its training data by asking for sensitive information.
Why? this is the answer
Adversarial attacks manipulate the input to exploit the model's internal logic and bypass its intended safety behavior, rather than directly altering its code or parameters. While other options describe model failures, they don't capture the specific 'magic trick' of bypassing alignment.
Just read this? Test yourself on what you have been reading.
Read the original → llm-vulnerability.github.io
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on llm — each one lists the topics its interview covers.
See open roles