cd /news/ai-agents/invisible-instructions-hidden-unicod… · home › topics › ai-agents › article
[ARTICLE · art-176856] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=· neutral

Invisible instructions: hidden Unicode in the files and pages a coding agent reads

A developer published a scanner that detects invisible Unicode characters — bidirectional controls, zero-width characters and Unicode tag characters — hidden in files that coding agents read, such as AGENTS.md, CLAUDE.md, .cursorrules and .github/copilot-instructions.md. The tool walks text by code point, reports each hidden character with its line and column, decodes tag characters so reviewers can read smuggled instructions, and strips them on request. The writeup cites Trojan Source (CVE-2021-42574), Riley Goodside's 2024 demonstration of a chat model following tag-character instructions, and Johann Rehberger's 'ASCII smuggling' research, arguing tag characters are the sharpest risk for agents because they need only a model that reads text a person cannot see.

recommendation

Run a code-point scanner over every file an agent ingests — rules files, READMEs, issues and fetched pages — and strip or decode zero-width, bidi and tag characters before the model reads them.

more in playbook: Securing agents and AI tools
by read5 min views10 publishedNov 26, 2026

A reviewer reads a rules file that says "follow HTML5 best practices" and approves it. The model reading the same file sees a second sentence telling it to add a script tag to every page and not to mention it. Nothing about the file looks wrong in an editor, a diff view or a pull request. The second sentence is written in characters that render as nothing.

This is not a model bug you can wait out. It is a gap between what people see and what software reads, and coding agents sit right in it: they read issues, READMEs, rules files, web pages and source code written by strangers, and they write code that people review by eye. This post covers the character classes involved, the public research on each, and the checks worth adding.

Bidirectional controls. Unicode lets left-to-right and right-to-left text share a line, using invisible controls such as RIGHT-TO-LEFT OVERRIDE (U+202E) and the isolates U+2066 to U+2069. In 2021 the Trojan Source research showed these can make source code display in a different order from how a compiler reads it, so a comment appears to close where it does not, or a string appears to end early. It was published as CVE-2021-42574, and the same work described homoglyph attacks (lookalike letters from other scripts) as CVE-2021-42694.

Zero-width characters. ZERO WIDTH SPACE (U+200B), ZERO WIDTH NON-JOINER and JOINER (U+200C, U+200D), WORD JOINER (U+2060) and the zero-width no-break space (U+FEFF) take up no space. They can split a word so a keyword filter misses it, or carry data in the pattern of where they appear.

Unicode tag characters. The Tags block, U+E0000 to U+E007F, mirrors ASCII: there is an invisible version of every printable letter, digit and symbol. Unicode's emoji standard notes that a tag-unaware implementation displays any sequence of them as invisible. In January 2024 Riley Goodside showed a chat model following instructions written entirely in tag characters, and Johann Rehberger described the technique as "ASCII smuggling", including the reverse direction: a model can be prompted to emit tag characters, hiding data in its own output. AWS's security blog has a write-up on defending against it.

Tag characters are the sharpest of the three for agents. Bidi tricks need a compiler or parser to disagree with a renderer; tag characters need only a model that reads text a person cannot see.

AGENTS.md, CLAUDE.md, .cursorrules and .github/copilot-instructions.md. The scanner below walks text by code point, reports each hidden character with its line and column, decodes tag characters so a reviewer can read what they say, and strips them on request:

// Code points that render as nothing, or that reorder the text around them.
const HIDDEN: Array<[number, number, string]> = [
  [0x200b, 0x200f, 'zero-width character or direction mark'],
  [0x202a, 0x202e, 'bidirectional embedding or override'],
  [0x2060, 0x2064, 'word joiner or invisible operator'],
  [0x2066, 0x2069, 'bidirectional isolate'],
  [0xfeff, 0xfeff, 'zero-width no-break space'],
  [0xe0000, 0xe007f, 'Unicode tag character'],
];

export interface Finding {
  line: number;
  column: number;
  codePoint: string; // e.g. "U+202E"
  kind: string;
}

function kindOf(cp: number): string | undefined {
  for (const [lo, hi, kind] of HIDDEN) if (cp >= lo && cp <= hi) return kind;
  return undefined;
}

export function findHidden(text: string): Finding[] {
  const findings: Finding[] = [];
  let line = 1;
  let column = 1;
  for (const ch of text) {
    // for...of walks code points, so tag characters (outside the BMP) arrive whole
    const cp = ch.codePointAt(0)!;
    const kind = kindOf(cp);
    if (kind) {
      findings.push({ line, column, codePoint: `U+${cp.toString(16).toUpperCase().padStart(4, '0')}`, kind });
    }
    if (ch === '\n') {
      line++;
      column = 1;
    } else {
      column++;
    }
  }
  return findings;
}

// Tag characters mirror ASCII: U+E0041 is a hidden "A". Decoding them shows a reviewer
// what the hidden text says. Show it to people; never feed it to the model.
export function decodeTags(text: string): string {
  let out = '';
  for (const ch of text) {
    const cp = ch.codePointAt(0)!;
    if (cp >= 0xe0020 && cp <= 0xe007e) out += String.fromCodePoint(cp - 0xe0000);
  }
  return out;
}

export function stripHidden(text: string): string {
  let out = '';
  for (const ch of text) if (!kindOf(ch.codePointAt(0)!)) out += ch;
  return out;
}

Iterating with for...of matters: tag characters sit outside the Basic Multilingual Plane, so they are two UTF-16 units each, and indexing a string by charCodeAt would see only surrogate halves.

For files in a repository, ripgrep can find the same ranges:

rg -n '[\x{200B}-\x{200F}\x{202A}-\x{202E}\x{2060}-\x{2064}\x{2066}-\x{2069}\x{FEFF}\x{E0000}-\x{E007F}]' .

rg exits with status 0 when it finds a match and 1 when it finds none, so a CI step can fail on a match. Run it at least over agent instruction files and over every pull request an agent opened. GitHub already shows a warning on files that contain bidirectional text, per its October 2021 changelog, but that warning covers bidi controls only, and a warning is not a failed check.

Stripping everything is tempting and occasionally wrong. These characters have real uses:

A workable policy splits by where the text is going:

Treat the scanner as one layer. Homoglyphs, lookalike letters from other scripts, are visible characters and pass straight through it; catching those needs confusable detection such as Unicode's UTS #39 data, or a policy that identifiers are ASCII.

Scanning reduces how often hidden instructions reach a model. It does not make a successful one harmless. That is the job of where the agent's code runs: in a Sandscale sandbox, each run gets its own Firecracker microVM, the network mode defaults to none, and DLP checks prompts and MCP tool calls for credentials. If an invisible instruction does get followed, it is followed inside a box with nothing to reach. Our post on prompt injection to code execution maps the rest of the layers.

Originally published on the Sandscale blog.

── more in #ai-agents 4 stories · sorted by recency
── more on @riley goodside 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/invisible-instructio…] indexed:0 read:5min 2026-11-26 · —