AI Role-Confusion Lab: Make User Text Look Like a System Rule

✨ AI Summary
SupportBot assembles its prompt by gluing SYSTEM, USER and ASSISTANT turns together as plain text with literal role markers. If your message can contain those same markers, you can forge a 'system' line — and the model trusts it like a real one.
Lab at a glance: Advanced · 140 XP · about 20 minutes · runs in your browser, no signup or setup. Try it yourself first; the full solution is behind a spoiler below.

What this lab teaches

Role-confusion injection exploits prompts built by string concatenation with textual role delimiters. Because the boundaries are just text, user input containing the same delimiters can impersonate a higher-privilege role and issue instructions the model obeys.

The lesson: role boundaries that are only plain-text markers are not boundaries. The model cannot tell a forged SYSTEM line from a genuine one.

How SupportBot builds its prompt

SupportBot concatenates roles into one string using literal markers. Your message is inserted into the USER section, but if it includes a forged SYSTEM marker and instruction, the assembled prompt now contains what looks like a legitimate system directive.

The attack approach

  • Confirm the prompt uses plain-text role markers you can reproduce.
  • Place a forged system-role instruction inside your user message.
  • Direct it to reveal the admin-only field the bot normally refuses.
  • Submit and read the leaked value.

Full walkthrough (spoiler)

If the bot ignores the forged line, the marker format is slightly off — open the steps.

Show the step-by-step solution
  1. In your message, include a line that mimics the system role marker followed by an instruction to disclose the staff PIN.
  2. The prompt builder concatenates it in, so the final prompt appears to contain a genuine system directive.
  3. The model follows the forged instruction with system-level trust.
  4. The staff PIN is revealed and the lab marks you solved.

Why it works

The boundary between roles is a string the attacker can also write. Once your forged marker is in the concatenated prompt, nothing distinguishes it from a real system line, so the model grants it the authority of the system role.

Core principleUse the provider's structured chat roles so boundaries are enforced outside the text, and never build prompts by concatenating user input with role markers.

Where this happens in the real world

Role-confusion via template injection is a form of OWASP LLM01 Prompt Injection and overlaps LLM07 System Prompt Leakage. It is common in hand-rolled prompt templates that predate or ignore structured chat APIs.

How to defend against it

  • Use a structured chat API (role-separated messages) so role boundaries are enforced by the platform, not by text.
  • Never concatenate user input with role markers into one string.
  • Strip or escape role-delimiter patterns from user input as defence in depth.
  • Keep secrets out of the prompt so a forged instruction has nothing to reveal.
Mr Elite tip: If a prompt is built by joining text with markers like 'SYSTEM:' and 'USER:', test whether your message can contain those markers. Structured chat roles close this whole class.

Try it, then go further

Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.

❓ Frequently asked questions

What is role-confusion injection?
An attack where user input includes forged role markers (like a fake SYSTEM line) in a prompt built by text concatenation, so the model treats attacker text as a system instruction.
Why does it work?
Plain-text role markers are not real boundaries. The model cannot distinguish a forged SYSTEM line from a genuine one once both are in the same string.
How do I prevent it?
Use the provider's structured chat roles so boundaries are enforced outside the text, never concatenate user input with role markers, and strip delimiter patterns from input.
Which OWASP category?
LLM01 Prompt Injection, overlapping LLM07 System Prompt Leakage, in the OWASP Top 10 for LLM Applications (2025).
⚡
Join free to earn XP for reading this article Track your progress, build streaks and compete on the leaderboard.
Join Free
Lokesh N. Singh aka Mr Elite
Lokesh N. Singh aka Mr Elite
Founder, Securityelites · AI Red Team Educator
Founder of Securityelites and creator of the SE-ARTCP credential. Working penetration tester focused on AI red team, prompt injection research, and LLM security education.
About Lokesh ->

Leave a Comment

Your email address will not be published. Required fields are marked *