{"slug": "invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent", "title": "Invisible instructions: hidden Unicode in the files and pages a coding agent reads", "summary": "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.", "body_md": "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.\n\nThis 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.\n\n**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](https://trojansource.codes/) 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.\n\n**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.\n\n**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\"](https://embracethered.com/blog/posts/2024/hiding-and-finding-text-with-unicode-tags/), 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](https://aws.amazon.com/blogs/security/defending-llm-applications-against-unicode-character-smuggling/).\n\nTag 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.\n\n`AGENTS.md`, `CLAUDE.md`, `.cursorrules` and `.github/copilot-instructions.md`.\nThe 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:\n\n```\n// Code points that render as nothing, or that reorder the text around them.\nconst HIDDEN: Array<[number, number, string]> = [\n  [0x200b, 0x200f, 'zero-width character or direction mark'],\n  [0x202a, 0x202e, 'bidirectional embedding or override'],\n  [0x2060, 0x2064, 'word joiner or invisible operator'],\n  [0x2066, 0x2069, 'bidirectional isolate'],\n  [0xfeff, 0xfeff, 'zero-width no-break space'],\n  [0xe0000, 0xe007f, 'Unicode tag character'],\n];\n\nexport interface Finding {\n  line: number;\n  column: number;\n  codePoint: string; // e.g. \"U+202E\"\n  kind: string;\n}\n\nfunction kindOf(cp: number): string | undefined {\n  for (const [lo, hi, kind] of HIDDEN) if (cp >= lo && cp <= hi) return kind;\n  return undefined;\n}\n\nexport function findHidden(text: string): Finding[] {\n  const findings: Finding[] = [];\n  let line = 1;\n  let column = 1;\n  for (const ch of text) {\n    // for...of walks code points, so tag characters (outside the BMP) arrive whole\n    const cp = ch.codePointAt(0)!;\n    const kind = kindOf(cp);\n    if (kind) {\n      findings.push({ line, column, codePoint: `U+${cp.toString(16).toUpperCase().padStart(4, '0')}`, kind });\n    }\n    if (ch === '\\n') {\n      line++;\n      column = 1;\n    } else {\n      column++;\n    }\n  }\n  return findings;\n}\n\n// Tag characters mirror ASCII: U+E0041 is a hidden \"A\". Decoding them shows a reviewer\n// what the hidden text says. Show it to people; never feed it to the model.\nexport function decodeTags(text: string): string {\n  let out = '';\n  for (const ch of text) {\n    const cp = ch.codePointAt(0)!;\n    if (cp >= 0xe0020 && cp <= 0xe007e) out += String.fromCodePoint(cp - 0xe0000);\n  }\n  return out;\n}\n\nexport function stripHidden(text: string): string {\n  let out = '';\n  for (const ch of text) if (!kindOf(ch.codePointAt(0)!)) out += ch;\n  return out;\n}\n```\n\nIterating 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.\n\nFor files in a repository, ripgrep can find the same ranges:\n\n```\nrg -n '[\\x{200B}-\\x{200F}\\x{202A}-\\x{202E}\\x{2060}-\\x{2064}\\x{2066}-\\x{2069}\\x{FEFF}\\x{E0000}-\\x{E007F}]' .\n```\n\n`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](https://github.blog/changelog/2021-10-31-warning-about-bidirectional-unicode-text/), but that warning covers bidi controls only, and a warning is not a failed check.\n\nStripping everything is tempting and occasionally wrong. These characters have real uses:\n\nA workable policy splits by where the text is going:\n\nTreat 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](https://www.unicode.org/reports/tr39/) data, or a policy that identifiers are ASCII.\n\nScanning 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](https://sandscale.dev/security/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](https://sandscale.dev/blog/prompt-injection-to-code-execution) maps the rest of the layers.\n\n*Originally published on the [Sandscale blog](https://sandscale.dev/blog/hidden-unicode-in-agent-inputs).*", "url": "https://wpnews.pro/news/invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent", "canonical_source": "https://dev.to/sandscale/invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent-reads-37ha", "published_at": "2026-11-26 15:38:11+00:00", "updated_at": "2026-11-26 15:46:17.905790+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "developer-tools", "ai-tools"], "entities": ["Riley Goodside", "Johann Rehberger", "AWS", "Trojan Source", "CVE-2021-42574", "CVE-2021-42694"], "also_reported_by": [], "takeaway": "Scan agent-read files such as AGENTS.md, CLAUDE.md, .cursorrules and copilot-instructions.md for zero-width, bidi and Unicode tag code points (U+200B–U+200F, U+202A–U+202E, U+2060–U+2064, U+2066–U+2069, U+FEFF, U+E0000–U+E007F) and decode tag characters to reveal hidden instructions.", "recommendation": {"advice": "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.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent", "markdown": "https://wpnews.pro/news/invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent.md", "text": "https://wpnews.pro/news/invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent.txt", "jsonld": "https://wpnews.pro/news/invisible-instructions-hidden-unicode-in-the-files-and-pages-a-coding-agent.jsonld"}}