Trojan Source Scanner
Find bidi overrides, zero-width characters and homoglyph identifiers. Analysis stays in this browser.
Source code
Up to 5 MB. Columns count Unicode codepoints; CRLF is normalized to LF.
Findings
Paste source code to scan it
Bidi controls, invisible characters, mixed scripts and homoglyph collisions are checked in this tab only.
About
Paste source or load a local text file to scan for the character-level tricks behind Trojan Source attacks: bidirectional controls, zero-width and invisible characters, mixed-script identifiers and homoglyph collisions with earlier tokens. Each finding includes an exact line and column, the invisible character made visible, and a short evidence excerpt. The annotated view marks findings in place; the sanitized preview removes controls and folds confusable letters to ASCII without changing your input. Everything runs locally — no network requests, no persistence.
Examples
Bidi override in a comment
function checkAccess(user) {
// \u202e administrator only
const isAdmin = false;
return isAdmin && user.active;
}bidi · line 2, column 7 · U+202E ⟨RLO⟩ — Bidi override control can make reviewed code render differently from how it compiles.The override changes visual order only; the compiled return statement still uses false.
Homoglyph identifier collision
const varianta = 'trusted';
const variant\u0430 = 'trusted';collision · line 2, column 7 — folds to "varianta", the same as "varianta" on line 1, column 7; plus a mixed-script finding for Latin + Cyrillic.The Cyrillic а renders like Latin a, so a reviewer can easily read two distinct variables as one.
Zero-width character, no emoji false positive
const visible\u200bValue = 1;
const emoji = '👨👩👦';invisible · line 1, column 14 — U+200B (ZERO WIDTH SPACE). The emoji ZWJ sequence on line 2 is not flagged.ZWJ is only suppressed between pictographs; between letters it remains a sanitization candidate.
About this tool
Trojan Source Scanner pinpoints the invisible characters that make reviewed source render differently from how it compiles. It checks the full Bidi_Control set (including U+061C ALM), zero-width and invisible-operator characters, TAG and Hangul filler characters, mixed-script identifiers under Unicode TR39 restricted sets, and homoglyph identifiers that collide with an earlier token after confusable folding.
Every finding carries the exact line and column, the codepoint name, a visible placeholder such as ⟨RLO⟩ for invisible controls, and a short context excerpt. The annotated view marks each finding in place; the sanitized preview removes controls and folds look-alike letters to ASCII where a mapping exists. The preview is read-only — your source is never rewritten, and letters without a safe ASCII look-alike are left alone instead of deleted.
The scan is language-agnostic and entirely local: no parsing, no network calls, no persistence. Category toggles and collision sensitivity let an auditor focus on one attack class, and CSV/Markdown export turns the evidence into a ticket-friendly report. If you want to strip or normalize invisible characters instead of locating them, use /text-cleaner; to inspect one character in detail, use /unicode-inspector.
What this tool does not do
- The bundled confusable table is a small subset of Unicode confusables.txt (~120 common Latin/Cyrillic/Greek pairs and fullwidth forms); exotic pairs can be missed.
- Script transliteration sensitivity is broader and can produce collisions that a strict confusable reading would not report.
- The scanner does not parse the language: bidi and invisible characters inside string literals are intentionally reported, and comment text is not distinguished from code.
- It verifies characters, not compiler semantics: runtime behavior, macro expansion and build-tool transformations are out of scope.
- Case-only differences (Var vs var) are not homoglyph collisions, and duplicate collision pairs are reported once with both line numbers.
- Findings are capped so pathological inputs cannot flood the DOM; the warning says when the cap was reached.
- A leading U+FEFF is treated as a BOM and ignored; positions use LF-normalized lines and 1-based codepoint columns.
- The sanitized view is a preview only. It strips controls and folds confusables where possible but never modifies the input, and it is not a general-purpose sanitizer (use /text-cleaner for that).
- Nothing is uploaded, persisted or logged; the tool makes no network requests.
How to use this tool
Paste or load source
Paste code into the input panel or choose a text file up to 5 MB. The scan runs in this tab as you type.
Choose what to check
Toggle bidi controls, invisible characters, mixed scripts and homoglyph collisions independently. Exact sensitivity uses the bundled confusable subset; script transliteration broadens collision matching.
Read the evidence
Open the findings table for line:column, severity, codepoint and context. Click a Jump button (or press Alt+↓/Alt+↑) to highlight the matching line in the annotated view.
Compare the renderings
Switch on the sanitized preview to see controls removed and homoglyphs folded to ASCII. A banner reminds you that this is a preview and the original input is unchanged.
Export the report
Copy the Markdown report or download CSV/Markdown for a security ticket. Re-scan after removing findings to see what remains.
Use cases
Audit vendor or dependency code
Screen third-party drops for bidi overrides and homoglyph identifiers before merging, with line-level evidence for the ticket.
Review an incoming pull request
Paste a changed file and jump between findings to check whether a suspicious identifier is intentional or an attack.
Train reviewers
Load the bidi sample, compare the annotated line with the sanitized preview, and demonstrate why rendered code cannot be trusted.
Triage false positives
Turn categories off individually when legitimate RTL comments or transliterated identifiers dominate the results.
Finding categories
| Category | What it covers |
|---|---|
| Bidi controls (high) | U+061C ALM, U+202A–U+202E LRE/RLE/PDF/LRO/RLO, U+2066–U+2069 LRI/RLI/FSI/PDI, U+200E/200F marks. |
| Invisible characters (low) | U+200B–U+200D, U+FEFF outside position 1, U+00AD, U+2060–U+2064, Hangul fillers, U+E0001 and TAG characters. |
| Mixed scripts (medium) | One identifier containing two or more TR39 restricted scripts, e.g. Latin plus Cyrillic. |
| Homoglyph collision (high) | Tokens identical after confusable folding but written differently, e.g. varianta and variant\u0430. |
| Annotated view | Affected lines with highlighted findings and visible placeholders; bidi-isolated spans keep placeholders readable. |
| Sanitized preview | Read-only line view with controls stripped and confusable letters folded where possible. |
Columns count Unicode codepoints (surrogate pairs count as one), and CRLF/CR line endings are normalized to LF for reporting.
Common mistakes
Mistake:Treating every non-ASCII character as an attack.
Fix:The scanner uses target tables and identifier-position heuristics; emoji, Arabic comments and Han identifiers produce no findings.
Mistake:Assuming a zero finding proves the source is safe.
Fix:The confusable table is a subset and there is no parser. Use the result as evidence to investigate, not as a verdict.
Mistake:Deleting a homoglyph letter to 'clean' an identifier.
Fix:The sanitized preview folds confusable letters to ASCII where possible and leaves unmapped letters intact; stripping them would change the identifier's meaning.
Mistake:Confusing a leading BOM with an embedded U+FEFF.
Fix:A U+FEFF at position 1 is ignored as a byte-order mark; elsewhere it is reported. The summary says when a BOM was stripped.
Mistake:Expecting the language hint to parse strings or comments.
Fix:The scan is intentionally language-agnostic: control characters are flagged anywhere, and script checks apply to identifier-like runs.
Frequently asked questions
What are bidi override characters?
Bidirectional controls tell a renderer to display text in a different direction than its logical order. Trojan Source attacks place characters such as U+202E (RIGHT-TO-LEFT OVERRIDE) or U+202D (LEFT-TO-RIGHT OVERRIDE) in comments and strings so a reviewer sees code that reads one way while the compiler sees another. The scanner flags the full Bidi_Control set, including U+061C ALM and the isolate characters U+2066–U+2069, and displays each as a visible placeholder like ⟨RLO⟩.
How do homoglyph identifier attacks work?
Some Cyrillic and Greek letters look nearly identical to Latin ones. An identifier written with Cyrillic а (U+0430) can look like the ASCII a while being a completely different variable. This tool scans identifier-like runs, reports mixed-script tokens under Unicode TR39 restricted sets, and flags tokens that become identical after confusable folding — showing both line numbers so you can compare them.
Which codepoints does the scanner flag?
Bidi controls: U+061C, U+200E–U+200F, U+202A–U+202E and U+2066–U+2069. Invisible characters: U+00AD, U+180E, U+200B–U+200D, U+2060–U+2064, U+115F, U+1160, U+3164, U+FEFF (except at position 1), U+FFA0, U+E0001 and TAG characters U+E0020–U+E007F. It also reports mixed-script identifiers and homoglyph collisions. A U+200D inside an emoji ZWJ sequence is deliberately not flagged.
Does the scanner change my code?
No. It is analysis only. The annotated view highlights findings in place, and the sanitized view is explicitly a read-only preview: it removes control characters and folds confusable letters to ASCII where a look-alike exists. Letters without a safe mapping are left alone rather than deleted, and the original source is never rewritten or downloaded.
Is my source uploaded anywhere?
No. The scan runs entirely in your browser tab. There are no API calls, no cookies for the input, and no server-side storage. Closing the tab discards everything. Choose a local file or paste text; either way it stays on your device.
Why isn't my emoji flagged for using a zero-width joiner?
ZWJ is the normal structural joiner in emoji sequences such as 👨👩👦. The scanner suppresses U+200D only when it sits between two pictographs; if the same character appears between letters in an identifier, it is reported as a low-severity invisible-character finding.
Does a clean result mean the file is safe?
No. The bundled confusable table is a subset of Unicode's data, the scan does not parse the programming language, and it checks characters rather than compiler semantics. A clean result means these specific patterns were not seen — use it as one signal in review, not as a security verdict.
What does the sanitized preview actually show?
Affected lines with bidi and invisible controls stripped and confusable letters folded to ASCII where a mapping exists. It is useful for seeing what a reviewer might expect the identifier to say. Because the preview can fold or remove characters, it is labelled 'preview only' and your original input remains untouched.
References & standards
Related tools
AES Encryption
Encrypt and decrypt text with AES-GCM and a passphrase, fully in your browser. Uses PBKDF2 key derivation and the Web Crypto API — your data and keys never leave your device.
Android Network Security Config Builder
Generate network_security_config.xml with cleartext rules, trust anchors, certificate pinning and debug-only CAs — plus the manifest snippet and file placement checklist.
Ansible Vault Encrypt/Decrypt
Encrypt secrets into $ANSIBLE_VAULT;1.1;AES256 format or decrypt vault content with its password — locally in your browser, drop-in compatible with ansible-vault.
Argon2 Hash Generator & Verifier
Generate Argon2id/2i/2d hashes with proper m/t/p parameters and verify PHC strings — reference algorithm in your browser, nothing uploaded.
AWS Signature V4 Builder
Build AWS Signature V4 headers and presigned URLs from a canonical request — signed curl, key chain and debug diff, computed locally in your browser.
Basic Auth Generator
Generate an HTTP Basic Authentication header from a username and password. Produces the Authorization header and ready-to-use curl and fetch snippets. Runs fully client-side.