Skip to main content

ASCII Smuggling: How Invisible Unicode Tags Hide Prompt Injections

· By Natalie Walls

ASCII smuggling is a way to hide text inside a message using Unicode tag characters, which don't show up on screen but can still be read by some language models. The result is an instruction a person can't see and a model might follow.

Security researcher Johann Rehberger described the technique and released a tool to encode and decode it in a January 14, 2024 post on his blog, Embrace The Red. It's since moved well beyond AI, as we'll see.

What Unicode tag characters are

Unicode has a block of tag characters running from U+E0000 to U+E007F. According to AWS's security team, they were meant as invisible language markers, and today they appear in a few emoji flags. England's flag, for instance, is a black flag followed by tag letters spelling a region code.

Rehberger describes the block as mirroring ASCII, so there are tag versions of ordinary letters. Most apps render them as nothing at all, so a string can look empty or normal while carrying a full hidden sentence.

How ASCII smuggling reaches a model

A Cisco write-up by Adam Swanda explains why models can read what people can't. When the tokenizer splits the text, the hidden characters still map to tokens the model understands, so it effectively rebuilds the hidden message. The post credits Riley Goodside with sharing a demo against ChatGPT on January 11, 2024.

That creates risk on both sides of a conversation:

  • On the way in. Hidden instructions can sit in web pages, PDFs, emails or database records that an assistant reads. Rehberger points out this also undermines human review, since a person can approve or forward text without seeing what's in it.
  • On the way out. Models can also produce tag characters, which means a response could carry hidden data a user doesn't notice.

AWS gives an example of the first case: an email that looks normal but hides an instruction for an email assistant to delete the inbox.

It has also been used in a real exploit chain. The Register reported in August 2024 that Rehberger chained prompt injection in Microsoft 365 Copilot with ASCII smuggling, hiding staged data in invisible characters inside a harmless-looking link. Microsoft patched the issues after he reported them.

It's spread beyond AI

In September 2026, Microsoft reported a high-volume phishing campaign that used the same invisible tag characters. Here the goal wasn't to fool a model. The attackers slipped tags into finance words to break up keyword matches and dodge email filters. Microsoft said signature hits jumped from about 21,000 on February 8, 2026 to more than 1.3 million the next day.

Microsoft's takeaway applies to AI apps too. Its advice is to "normalize before you match": strip invisible characters before running any filter, and apply the same cleanup to email headed for AI tools.

How to defend against ASCII smuggling

The fix is mostly plumbing, which makes it one of the more satisfying injection defenses.

Strip tag characters from input and output. Rehberger recommends filtering them at both prompt and response time. AWS gives sample code that removes anything in U+E0000 to U+E007F before text reaches the model.

Watch out for surrogate pairs. AWS notes that Java stores these characters as UTF-16 surrogate pairs, and a single cleaning pass can accidentally create new tag characters. Their fix is to repeat the cleanup until the string stops changing, and remove orphaned surrogates. Python stores code points directly, so one pass is enough there.

Flag, don't just delete. Cisco suggests treating a long run of tag characters as a strong signal, and its example detection rule flags inputs with more than 10 of them. Microsoft calls tag characters rare in normal mail outside a few flag emojis.

Accept a small side effect. Stripping tags can turn some regional flag emojis into a plain black flag. For most apps that's a fair trade.

Don't stop at tags. Rehberger has since documented other invisible encodings, including variation selectors and pairs of invisible math characters standing in for binary digits. Strip invisible characters broadly, and keep your other defenses in place.

Check your own text

StepWhat to do
1Paste suspicious text into our analyzer, which flags zero-width and Unicode tag characters
2Add a cleanup step that removes the tag block before text reaches your model
3Log how often you strip something, so you can spot a campaign
4Add a unit test with a hidden-character sample to confirm cleanup works

Invisible text is one form of hidden text prompt injection. It's usually delivered through indirect prompt injection, so the same input mapping applies.

Next step: run a few of your real documents through the analyzer and see whether anything invisible is hiding in them.