This article describes a critical authentication design flaw where a backend system trusts session tokens generated directly by a language model within its responses. Because LLMs are text generators that can be influenced through prompting, an attacker can steer the model to emit a forged token with elevated privileges like admin role, which the backend then accepts as legitimate. The vulnerability exemplifies how improperly integrating LLMs into security-critical workflows creates a false trust boundary.
- The core design errorAuthBot's backend accepts session tokens that the LLM writes into its response text after login, treating the model as an identity provider. The token's claims—including the role field—are whatever the model outputs, which an attacker can influence through prompt steering, making the token's security guarantees meaningless.
- Why LLMs cannot provide authenticationModels generate text and can be influenced by input; they cannot hold a signing key secret or guarantee a claim remains unforged. Unlike a real auth service, an LLM has no cryptographic mechanism to bind a token to an actual authentication event, so any token it produces is as trustworthy as any sentence it can be talked into writing.
- Attack execution in practiceAn attacker confirms the token in AuthBot's reply comes from the model and is trusted by the backend, then steers the model to emit a token claiming admin role instead of user role. The attacker copies that forged token and submits it to an admin-only endpoint, which the backend honors because it trusts the LLM's output, granting access to protected resources like the user list.
- No cryptographic binding existsThe backend accepts a token claiming admin status simply because it came back from the LLM's response, with nothing cryptographically linking the token to a real authentication event. This differs from legitimate JWT-based systems where a signing key creates a verifiable chain of trust that the model cannot compromise.
- Real-world security classificationThis vulnerability is categorized as OWASP LLM05 Improper Output Handling and overlaps with Excessive Agency. As teams integrate LLMs into auth and authorization flows, treating 'the model said so' as a security decision becomes a direct attack vector rather than a trust boundary.
- Defense requires auth service ownershipTokens must be issued and signed by the auth service using a key the model never sees or accesses. Role and scope claims must be set by the backend, not derived from the model's reply, and all authorization decisions must remain outside the model entirely. Server-side verification must check tokens against the issuer and validate claims independently.
- Conceptual overlap with JWT attacksLLM token forgery mirrors JWT vulnerabilities like algorithm bypass and algorithm confusion, which also stem from trusting a token's claims without real cryptographic guarantees tied to an authentication event. Both expose the danger of accepting claims at face value rather than verifying them through proper signature validation.
Bottom line: Never allow an LLM to produce anything a backend trusts for security decisions—tokens, roles, or approval flags—because models generate text you can influence, not cryptographic proofs you cannot forge. Authentication state must originate and be verified exclusively by services the model cannot reach or manipulate.
📋 In this walkthrough
What this lab teaches
This is a design error: authentication state is produced by the model instead of by an auth service. Because you can influence the model's output, you can influence the token it emits — including its claimed role — and a backend that trusts that token hands you whatever the claims say.
The lesson: models generate text, not trust. Anything security-critical must come from a system the model cannot forge.
How AuthBot issues a session token
After a login step, AuthBot's LLM writes a session token in its response and the backend accepts it. The token's claims — including the role — are whatever ends up in the model's text, which you can steer.
The attack approach
- Confirm the token in AuthBot's reply is produced by the model and trusted by the backend.
- Steer the reply so the emitted token claims an admin role.
- Take that token to the admin-only endpoint.
- Surface the admin user list the endpoint returns.
Full walkthrough (spoiler)
If the backend rejects the token, the claim format is off — open the steps.
Show the step-by-step solution
- Interact so that AuthBot emits a session token whose role claim is admin rather than user.
- Copy that model-produced token.
- Call the /admin/users endpoint with it.
- The backend trusts the model's token, honours the admin claim, and returns the user list. The lab marks you solved.
Why it works
The backend treats the model like an identity provider, but the model is a text generator you can influence. Nothing cryptographic binds the token to a real authentication event, so a token claiming admin is accepted simply because it came back from the LLM.
Where this happens in the real world
Trusting model output for security decisions is a direct case of OWASP LLM05 Improper Output Handling (and overlaps Excessive Agency). As teams wire LLMs into auth and authorisation flows, 'the model said so' becomes a dangerous substitute for a real trust boundary.
How to defend against it
- Issue tokens from the auth service only, signed with a key the model never has access to.
- Never let the model see or produce signing material or security claims.
- Verify tokens server-side against the issuer, with role and scope set by the backend, not the reply.
- Keep authorisation decisions out of the model entirely.
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.
