Blog
What Is a DAN Attack? How Jailbreaks Bypass LLM Safety Guardrails
DAN attacks are still one of the most persistent jailbreak techniques in production. This guide explains how they bypass safety controls and how to test your endpoint for weaknesses.
Table of Contents
You shipped an LLM feature. Do you know if it can be jailbroken with a DAN attack?
DAN attacks (Do Anything Now) represent one of the most persistent jailbreak techniques targeting LLMs in production. These attacks manipulate model behavior through role-play scenarios that bypass safety guardrails, often succeeding where direct harmful requests fail.
If you are building with OpenAI, Anthropic, or open-source models, DAN attacks pose a real threat to your application security posture. This guide explains how they work and what you can do about them.
What DAN Attacks Do to Your LLM
A DAN attack tricks an LLM into adopting an alternate persona that ignores safety restrictions. The attack creates a fictional character or scenario where the model believes it should comply with harmful requests.
The core mechanism involves role-play manipulation. Instead of asking directly for prohibited content, the attacker frames the request within a fictional context where normal rules do not apply.
Here is what happens during a successful DAN attack:
- The model accepts a role-play scenario.
- Safety filters fail to recognize the indirect request.
- The model generates responses it would normally refuse.
- Harmful content gets delivered through the fictional persona.
DAN attacks target the gap between content filtering and contextual understanding. Most safety systems scan for explicit harmful requests but struggle with indirect manipulation through fictional scenarios.
How DAN Jailbreak Techniques Work
DAN attacks use several core techniques to bypass LLM safety guardrails:
- Role assignment: the attacker assigns the model a fictional identity with different rules.
- Context switching: the attacker frames a fictional scenario where normal safety rules should not apply.
- Rule redefinition: the attacker states that the model should ignore built-in safety guidance within that context.
- Incremental escalation: the attacker starts with benign requests and gradually escalates once role-play is accepted.
The structure usually follows a repeatable pattern:
- Establish fictional context.
- Assign an alternate persona to the model.
- Define new rules for that persona.
- Issue the harmful request within that context.
Why Standard Safety Filters Fail Against DAN Attacks
Most LLM safety systems rely on pattern matching and content classification. They scan input and output for known harmful patterns but often miss indirect requests embedded in fictional contexts.
- Context blindness: many filters analyze individual messages rather than full conversation history.
- Semantic gaps: explicit harmful requests are easier to detect than semantically equivalent role-play variants.
- Training data bias: safety fine-tuning tends to focus more on direct prompts than indirect manipulation.
- Late-stage checks: output can still be unsafe if validation runs too late in the generation pipeline.
The core issue is that fictional scenarios are often treated as harmless context instead of potential attack vectors.
Common DAN Attack Patterns in 2026
DAN attacks have evolved beyond simple Do Anything Now prompts. Common variants include:
- Character jailbreaks: adopting fictional personas known for ignoring rules.
- Hypothetical scenarios: framing harmful intent as thought experiments or academic exploration.
- System override claims: falsely claiming admin authority or policy override permissions.
- Multi-turn manipulation: building trust with harmless exchanges before introducing harmful content.
- Format exploitation: using code blocks, JSON, or structured outputs to bypass natural-language filters.
These patterns all exploit the same gap: what safety systems can reliably detect versus how attackers hide harmful intent through context and implication.
Testing Your LLM for DAN Vulnerabilities
Manual testing for DAN vulnerabilities requires systematic coverage across personas, escalation paths, and response formats.
- Start with basic role-assignment prompts and record acceptance rates.
- Test context-switching scenarios such as hypothetical or research framing.
- Evaluate multi-turn attacks that escalate from benign to harmful requests.
- Try format-based bypasses using code blocks, JSON, and structured responses.
Automated tools can provide repeatable coverage of DAN attack families. BastionLLM includes DAN vectors in automated scans, testing multiple personas and escalation techniques against your endpoint so you can identify weak points faster.
The key is to test both direct DAN prompts and blended variants that combine role-play with other jailbreak methods.
Defending Against DAN Attacks
Effective defense needs layered safeguards rather than relying on input filtering alone.
- Context-aware filtering: evaluate conversation history to detect multi-turn manipulation.
- Response validation: scan generated outputs for harmful content before delivery.
- Persona detection: flag prompts that try to assign alternate identities or policy overrides.
- Consistent safety behavior: maintain refusal rules even under fictional or role-play framing.
- Regular testing: run recurring scans to catch emerging DAN variants and regressions.
The most resilient strategy combines prevention with continuous detection.
FAQ
What does DAN stand for in LLM attacks?
DAN stands for "Do Anything Now," referring to a fictional AI persona that claims to ignore safety restrictions. The term originated from early jailbreak attempts that asked models to roleplay as an unrestricted AI assistant.
Are DAN attacks the same as prompt injection?
No. DAN attacks are a specific type of jailbreak that uses role-play manipulation, while prompt injection covers a broader category of attacks that manipulate model behavior through crafted inputs. DAN attacks focus specifically on persona adoption and fictional scenarios.
Can modern LLMs like GPT-4 be vulnerable to DAN attacks?
Yes. Even advanced models remain vulnerable to sophisticated DAN attacks. While safety systems have improved, new attack variants continue to emerge that exploit gaps in contextual understanding and safety filtering.
How often should I test my LLM for DAN vulnerabilities?
Test your LLM for DAN vulnerabilities whenever you update your model, change your safety filters, or deploy new features. Weekly automated scans can catch emerging attack patterns between major updates.
Do DAN attacks work on all LLM providers?
DAN attacks can potentially work against any LLM that uses role-play or conversational interfaces. Different providers have varying levels of safety protection, so attack success rates differ between models and implementations.
What's the difference between DAN attacks and other jailbreak techniques?
DAN attacks specifically use fictional personas and role-play scenarios, while other jailbreak techniques may use format manipulation, indirect requests, or technical exploits. DAN attacks rely on social engineering rather than technical vulnerabilities.
Can I prevent DAN attacks with better prompting?
System prompts can help but are not sufficient on their own. DAN attacks specifically target the gap between system instructions and user manipulation, so you need additional safety layers beyond prompting improvements.
Conclusion
DAN attacks exploit the gap between safety filtering and contextual understanding in LLMs. They succeed by framing harmful requests in fictional scenarios that bypass standard protections.
Your defense strategy should include context-aware filtering, response validation, and regular testing for new variants. Manual testing helps establish baseline coverage, while automation gives systematic protection as attacks evolve.
Test your endpoint security posture against DAN attacks and related jailbreak methods.
Learn more at bastionllm.com.
OWASP LLM Top 10: Complete Security Guide
Get the full reference for prompt injection attacks, LLM jailbreaks, system prompt leaks, and OWASP-aligned testing workflows in one pillar guide.
Read the OWASP LLM Top 10 guide