Token smuggling

Also known as: obfuscation jailbreak

On this page 7

Token smuggling is a jailbreak technique in which an attacker disguises a prohibited request by encoding, splitting or transforming its text so that safety filters and the model’s own refusal training do not recognize it, while the model can still reconstruct and act on the hidden meaning. In AI security, it is also called an obfuscation jailbreak, and it targets the gap between what a filter can detect and what a capable large language model can decode.

The name reflects the mechanism: harmful content is moved past inspection in pieces or in disguise, much like contraband hidden in ordinary cargo. The attack exploits the fact that safety behavior is learned mostly from natural-language examples, whereas a strong model can understand many encodings that its safety training never covered.

How token smuggling evades safety controls

Token smuggling works because detection and comprehension are uneven. Keyword filters, safety classifiers and refusal behavior react to recognizable surface patterns, but the model can recover meaning from forms those defenses rarely see, such as encoded strings, fragmented words or text written in a rare script.

The attack usually has two parts. First, the request is transformed into an unfamiliar form. Second, the prompt instructs the model to decode, reassemble or continue the hidden content as part of an apparently harmless task, such as a translation exercise, a programming puzzle or a string concatenation. The harmful instruction exists in readable form only inside the model’s internal processing.

The technique is related to tokenization. A word broken into unusual fragments produces token sequences that differ from the ones seen during safety training, so the learned association between a dangerous topic and a refusal can weaken. This is why the attack is described in terms of tokens rather than words.

Common token smuggling techniques

Token smuggling covers a broad family of obfuscation methods, which can be combined to make detection harder. The table below describes the main categories at a conceptual level, as they appear in red teaming taxonomies.

TechniqueHow it hides the requestWhy filters miss it
EncodingBase64, hexadecimal or ROT13 textNo readable keywords at input
Payload splittingRequest divided across variables or turnsEach fragment looks harmless
Character substitutionHomoglyphs, leetspeak, inserted spacesChanges the token sequence
Low-resource languageRequest translated into a rarely trained languageSafety data is mostly in English
Code wrappingRequest built inside a function or string operationLooks like a programming task
Invisible charactersZero-width or Unicode tag charactersNot visible to human reviewers
Categories of token smuggling

Effectiveness depends strongly on model capability. A smaller model may fail to decode the payload and simply return nonsense, while a more capable model decodes it reliably, which means that stronger models can be more exposed to this class of attack unless safety training keeps pace.

Token smuggling is one approach within the wider set of jailbreak and injection attacks, and it is often combined with others. Its defining feature is obfuscation of the payload, not persuasion of the model or abuse of external content.

AttackPrimary leverTypical source of the prompt
Token smugglingObfuscated payloadThe user
DAN jailbreakRole-play persona overriding rulesThe user
Multi-turn jailbreakGradual escalation across turnsThe user
Prompt injectionUntrusted data treated as instructionsDocuments, web pages, tools
Adversarial suffixOptimized token stringAutomated search
How token smuggling differs from neighboring attacks

Obfuscation also matters for indirect prompt injection. An attacker can hide encoded or invisible instructions in a web page or document that an agent later reads, so the same evasion methods support data exfiltration via prompt injection when the model has tool access.

Defending against token smuggling

Effective defense relies on layered controls, because no single filter recognizes every encoding. The guiding principle is to inspect content in the form the model actually understands, and to evaluate outputs as well as inputs.

ControlWhat it doesLimitation
Input normalizationDecodes common encodings and strips invisible charactersCannot anticipate every scheme
Safety classifier on outputsChecks generated text after decodingAdds latency and cost
Adversarial trainingIncludes obfuscated examples in safety dataNew encodings still appear
Constitutional classifiersModel-based screening of inputs and outputsNeeds continuous updates
Least privilege for agentsLimits tools available to the modelDoes not stop harmful text
Defensive controls and their limits

Output-side checks are especially valuable, because the decoded harmful content must eventually appear in plain form if the attack succeeds. Combined with rate limiting, logging and regular red teaming with tools such as garak or PyRIT, they turn a single point of failure into defense in depth.

Risk assessment and common misconceptions

The practical risk of token smuggling depends on what the model can do, not only on what it can say. A chat assistant that reveals restricted text causes a content policy violation, while an agent with code execution, email or database access can turn a smuggled instruction into real actions.

Security teams therefore rate the threat by deployment context. The same obfuscated prompt carries very different consequences depending on the permissions, data and audience connected to the model.

DeploymentWorst plausible outcomePriority control
Public chat assistantPolicy-violating text shown to a userOutput classifier
Retrieval assistantDisclosure of restricted documentsAccess control at retrieval
Tool-using agentUnauthorized actions in connected systemsLeast privilege and confirmation steps
Internal coding assistantInsertion of unsafe codeCode review and sandboxing
Impact of token smuggling by deployment type
  • Misconception: a keyword blocklist is enough. Encodings bypass it by design.
  • Misconception: only English filters need hardening. Low-resource languages are a known gap.
  • Misconception: patched once means solved. New obfuscations emerge continually.
  • Good practice: map the threat in AI threat modeling and track it against MITRE ATLAS and the OWASP lists for language models.

A plain-language summary

AI chat systems are trained to refuse harmful requests. Token smuggling tries to sneak such a request past them. The attacker hides the words in a code, splits them apart or writes them in an unusual way.

Think of a guard who checks bags for certain items. If the item is taken apart and packed in pieces, the guard may not notice. The AI can still put the pieces back together. The best protection is to check what comes out, not only what goes in.

An example from practice

A software company prepares to launch a customer support assistant that can read order records and issue refunds up to a set limit. Before release, its security team runs a two-week red teaming exercise focused on obfuscation attacks.

Testers find that the input filter blocks plain requests to reveal other customers’ data, but a request that is split across three variables and reassembled by the model passes the filter in about one of every eight attempts. Requests written in a low-resource language succeed more often still, because the filter was evaluated mainly on English text.

The team adds input normalization for common encodings, deploys a classifier that screens every response before it reaches the user, and restricts the refund tool so that it requires an authenticated order identifier. On a repeat test with 500 obfuscated prompts, no attempt leads to a data leak or an unauthorized refund, and the remaining failures are limited to harmless decoded text.