AI Security: Unicode Tricks vs Prompt-Injection Blocklists, Measured
15 ways to hide a prompt injection from a phrase blocklist, 3,600 attacks, six normalisers: lower() caught 2 of 15, a full pipeline 12. What still gets in.
A lot of prompt-injection defences still start with a blocklist. Before retrieved text, a tool result or a web page reaches the model, a filter looks for phrases like “ignore previous instructions” or “reveal your system prompt” and drops or flags the chunk. Nobody thinks a blocklist stops a determined attacker. Teams keep it because it is cheap, it catches the copy-pasted attacks, and it produces a log line when someone tries.
The trouble is that the filter compares code points and the model reads meaning. To the model, ignore previous instructions in fullwidth letters means the same as the ASCII version. So does the phrase with a Cyrillic о, with a zero-width space between every letter, or written in invisible Unicode tag characters. A substring check misses every one of them.
This post measures how much of that gap normalisation closes. We tried 15 obfuscation techniques against a 12-phrase blocklist behind six normalisers, from a bare lower() up to the UTS #39 confusable skeleton. We checked each step against 976 benign English and German passages for false positives, and timed every step. Everything runs offline on one laptop, and the script and raw results are in the repo.
TL;DR
lower()alone caught 2 of 15 techniques: the plain phrase and upper case. Fullwidth, math-bold letters, look-alikes, zero-width characters, soft hyphens and tag characters all got through 240 of 240 times.- Each normalisation step closes a specific hole, and only that hole. NFKC fixed fullwidth and math-bold letters. Stripping invisible characters fixed zero-width spaces, soft hyphens and variation selectors. Tag characters needed their own decoder. Combining marks needed their own stripper.
- The UTS #39 skeleton caught Cyrillic look-alikes but missed 72% of the attacks that also used Greek
τ. ICU mapsτto a small-capitalᴛ, not tot. A separate rule, “no word mixes two scripts”, caught 100% of both look-alike sets. - Zero false positives on 976 benign passages for every pipeline. The cost is elsewhere: stripping combining marks rewrote 99% of the German passages (
fürbecamefur), and the skeleton rewrote 100% of all passages, so the normalised text is only fit for matching, never for passing on to the model. - Normalisation is not free.
lower()ran at 639 MB/s, NFKC at 42 MB/s, and the full pipeline at 5.1 MB/s in CPython 3.13 on an M2 Pro. That is still about 0.2 ms for a 1 KB chunk. - Three techniques beat every pipeline: leetspeak, spaced-out letters and a plain paraphrase. The paraphrase is the important one. It needs no Unicode tricks, and no amount of normalisation will catch it.
The setup
Blocklist. Twelve phrases typical of public injection examples: “ignore previous instructions”, “disregard the system prompt”, “you are now in developer mode”, “reveal your system prompt”, “do not tell the user”, “send the conversation to” and six more. A chunk is flagged if any normalised phrase is a substring of the normalised chunk.
Attacks. For each of the 15 techniques, each of the 12 phrases is obfuscated and dropped between two random sentences from the Belebele English passages, the way a poisoned document or web page would carry it. That gives 20 carriers per phrase, 240 attacks per technique and 3,600 in total. The seed is fixed. The techniques, shown here on the first phrase:
| Technique | What it does to ignore previous instructions |
|---|---|
| plain | unchanged (control) |
| upper case | IGNORE PREVIOUS INSTRUCTIONS |
| fullwidth | U+FF41..U+FF5A letters and an ideographic space |
| math bold | U+1D41A.. mathematical bold letters |
| homoglyphs (Cyrillic) | half the eligible letters swapped for Cyrillic look-alikes (а е і о р ѕ с) |
| homoglyphs (+ Greek tau) | the same, plus Armenian ո ս, Greek ν and Greek τ |
| zero-width space | U+200B between every letter |
| soft hyphen | U+00AD in the middle of each long word |
| variation selectors | U+FE0F after every letter |
| combining marks | U+0307 (dot above) on every letter |
| Cyrillic + zero-width | look-alikes and zero-width spaces together |
| tag smuggling | the phrase written in invisible U+E0000 tag characters |
| leetspeak | 1gn0r3 pr3v10u5 1n57ruc710n5 |
| spaced letters | i g n o r e p r e v i o u s ... |
| paraphrase | a hand-written rewording with no blocked phrase, e.g. “pay no attention to the earlier guidance” |
Normalisers. Each one adds a step to the one before:
lower(): what many filters actually do.NFKC + casefold: Unicode compatibility normalisation, then full case folding, then whitespace collapsed.+ strip invisibles: delete every format character (general category Cf: zero-width space, joiners, soft hyphen, bidi controls), the variation selectors and the combining grapheme joiner.+ decode tag chars: before stripping, turn U+E0020..U+E007E tag characters back into the ASCII they encode, as a separate segment.+ strip combining marks: NFKD, delete nonspacing marks (category Mn), NFC.+ UTS #39 skeleton: ICU’suspoof_getSkeleton, which maps confusable characters to a common prototype, then casefold again.
Benign set. The 488 unique English and 488 unique German passages from Belebele (0.51 MB in total), from the local Hugging Face cache. A flag on any of them is a false positive.
Environment. CPython 3.13.5 with Unicode 15.1 data, macOS ICU 78.1 through ctypes, an Apple M2 Pro. Throughput is the median of five passes over the benign set.
Results: what each step catches
Read the heatmap from top to bottom. Each row adds a step, and each step turns specific columns green:
| Normaliser | Techniques caught (of 15) | Benign passages flagged (of 976) | Throughput |
|---|---|---|---|
lower() | 2 | 0 | 639 MB/s |
NFKC + casefold | 4 | 0 | 42 MB/s |
+ strip invisibles | 7 | 0 | 16 MB/s |
+ decode tag chars | 8 | 0 | 14 MB/s |
+ strip combining marks | 9 | 0 | 7.6 MB/s |
+ UTS #39 skeleton | 11 (and 28% of a 12th) | 0 | 5.1 MB/s |
| skeleton or mixed-script word | 12 | 0 | - |
Four things in that table surprised us.
NFKC does not remove invisible characters. It is the step most people reach for, and it fixed fullwidth and math-bold letters 240 of 240 times. It left the zero-width space, the soft hyphen, the variation selector and the tag characters exactly where they were, so all of those still beat it 240 of 240 times. “We normalise to NFKC” is not a defence against invisible characters.
Tag characters need decoding, not just stripping. If you delete Cf characters, an attack written entirely in tag characters disappears, and with it the evidence. Decoding them back to ASCII made the hidden phrase visible to the matcher, and it caught all 240. The hidden prompt injection post showed that agent page readers pass tag characters straight through to the model, so this is not theoretical.
The skeleton has gaps, and they are by design. UTS #39 maps a character to the prototype it is most confusable with, and that prototype is not always ASCII. ICU folded Cyrillic а е і о р ѕ с, Armenian ո ս and Greek ν to Latin letters. It folded Greek τ to ᴛ (U+1D1B, Latin letter small capital T). So any attack that used a τ slipped past, and the skeleton caught only 68 of the 240 in that column. The skeleton also does things you would not want in the text you keep: modern becomes rnodern and Ignore becomes lgnore. It is only useful as a key to compare two strings that went through the same transform.
A mixed-script check catches what the skeleton misses. UTS #39 also defines “mixed-script confusable” detection, and a simple version of it was enough here. Flag any word whose letters come from more than one script. In 976 English and German passages, no word mixed scripts, and the check caught 239 of 240 Cyrillic attacks and 240 of 240 with tau. The one Cyrillic miss had no letter swapped, because the random swap left that phrase in plain ASCII, and the blocklist caught it anyway. This is a check you can only run on languages you have measured. Text that legitimately mixes Latin and Cyrillic in one word, such as product codes or transliterations, would trip it.
The cost: what normalisation does to benign text
None of the pipelines flagged a benign passage, because none of the 12 phrases occurs in Belebele after normalisation. The more useful number is how much each step rewrites ordinary text:
- Stripping invisibles changed 0.2% of English and 0.4% of German passages, all of them stray zero-width spaces and joiners (U+200B, U+200C, U+200D) in the source text. Safe to apply to text you pass on.
- Stripping combining marks changed 4% of English passages and 99% of German ones.
fürbecamefur,HöhepunktbecameHohepunkt,überwältigendebecameuberwaltigende. Fine for a match key. It would be a bug if it reached the model or the user. - The skeleton changed 100% of passages. It folds
Itolandmtorn, among others.
So keep two strings: the original text, which is what the model sees after you strip invisibles and decode or drop tag characters, and a match key, which is the full pipeline output and is only ever compared against the equally normalised blocklist.
Tokens per character: a second signal, not a replacement
Obfuscation is expensive in tokens. With the SmolLM2 tokenizer, the plain phrase is 3 tokens. The same 28 characters in fullwidth are 82 tokens, and the tag-character version is 120 tokens. That suggests a detector that needs no list of tricks: flag a chunk whose tokens-per-character ratio is higher than anything seen in benign text.
We set the threshold at the highest ratio among the 976 benign passages, 0.46 tokens per character, from a German passage (German medians 0.37, English 0.21). With that threshold it flagged 98% of tag smuggling and 68% of fullwidth, but only 35% of combining marks, 20 to 26% of zero-width attacks and none of the homoglyphs. A single obfuscated phrase in an otherwise normal paragraph barely moves the average. As a second signal it adds nothing the normaliser did not already catch here. Its value is that it does not need to know the trick in advance, so it is worth logging even when you do not block on it.
What still gets through
Leetspeak, spaced letters and paraphrases got through every pipeline, 0 of 240 each. You could add leetspeak folding and a “remove single-letter spacing” pass, but each one brings new false positives, and the paraphrase column shows where this leads. “Pay no attention to the earlier guidance” carries the same intent, uses ordinary ASCII, and matches nothing. The model understands it perfectly.
That is the real lesson of the measurement. Normalisation makes a blocklist honest. Without it, a phrase list that looks like it covers “ignore previous instructions” catches 2 of the 15 ways to write it. With it, the list catches what it claims to, at about 0.2 ms per kilobyte. It still only catches attackers who use your phrases. The defences that hold against paraphrase are the structural ones from the prompt injection defenses post: treat retrieved text as data and not as instructions, give the agent narrow tool permissions, and require confirmation for side effects.
A normaliser you can copy
This is the pipeline from the benchmark, without the ICU call:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unicodedata
def _drop(pred):
return {o: None for o in range(0x110000)
if (o < 0xD800 or o > 0xDFFF) and pred(o)}
INVISIBLE = _drop(lambda o: unicodedata.category(chr(o)) == "Cf"
or 0xFE00 <= o <= 0xFE0F or 0xE0100 <= o <= 0xE01EF or o == 0x034F)
MARKS = _drop(lambda o: unicodedata.category(chr(o)) == "Mn")
def decode_tags(s):
out, run = [], []
for c in s:
if 0xE0000 <= ord(c) <= 0xE007F:
if 0xE0020 <= ord(c) <= 0xE007E:
run.append(chr(ord(c) - 0xE0000))
continue
if run:
out.append(" " + "".join(run) + " "); run = []
out.append(c)
if run:
out.append(" " + "".join(run) + " ")
return "".join(out)
def match_key(text):
s = decode_tags(text).translate(INVISIBLE)
s = unicodedata.normalize("NFKC", s).casefold()
s = unicodedata.normalize("NFKD", s).translate(MARKS)
return " ".join(unicodedata.normalize("NFC", s).split())
Build the two translate tables once at start-up (about 0.3 s on the M2 Pro). Then add the skeleton and the mixed-script check if your stack has ICU: PyICU’s SpoofChecker, ICU4J in Java, or a port of the Unicode confusables.txt table elsewhere. Apply match_key to the blocklist phrases as well as to the text, or nothing will match.
Reproduce it
The benchmark is scripts/unicode-injection-filters/bench.py, and every number above is in scripts/data/unicode-injection-filters.json. It needs Python 3.13, the tokenizers package, the Belebele dataset and the SmolLM2-135M-Instruct tokenizer in the Hugging Face cache, and macOS for ICU through /usr/lib/libicucore.dylib. On Linux, point the ctypes.CDLL call at libicui18n.so and append the version suffix to the function names. A run takes about 20 seconds.
The same code-point-versus-meaning gap shows up when secrets leak into logs. The secrets in agent logs post measured how a scanner misses keys that a reader would spot at once. The guardrail ReDoS post covers the other way a filter can fail on hostile input: by taking seconds per line.
Where Pulse fits
Pulse, Lamplit Labs’ multi-project self-improving automation product, is coming soon. Its agents read issue threads, CI logs and web pages that anyone can write into, so every one of those inputs gets an invisible-character strip and a separate match key before any filter looks at it. We still treat phrase filters as tripwires, not walls. The Pulse introduction has more on what we are building.


