Unicode UTS #39 Confusable Skeletons, CVE-2021-42574 Trojan Source & Thompson NFA ReDoS Bounds
Modern pull requests, legal drafts, and LLM outputs routinely carry invisible zero-width joiners, bidirectional display overrides, or cross-script lookalike characters—while naive regex validators expose servers to single-request CPU exhaustion. Below is the deterministic automata and Unicode normalization math powering Destiny’s forensic scanners.
1. Bidirectional Control Stack & Invisible Format Code Points
Under Unicode Standard Annex #9 (UAX #9), directional overrides and isolates push display-direction frames onto a per-line stack (max depth 125). Any unterminated frame crossing a string literal, comment delimiter, or newline boundary triggers a deterministic CVE-2021-42574 alert alongside invisible watermark detection:
BIDI_OPEN = { U+202A (LRE), U+202B (RLE), U+202D (LRO), U+202E (RLO), U+2066 (LRI), U+2067 (RLI), U+2068 (FSI) }
BIDI_CLOSE = { U+202C (PDF), U+2069 (PDI) }
ZERO_WIDTH = { U+200B (ZWSP), U+200C (ZWNJ), U+200D (ZWJ), U+2060 (WJ), U+FEFF (BOM) }2. Canonical Decomposition (NFD) & UTS #39 Confusable Equivalence
Two strings X and Y are visually confusable under Unicode Technical Standard #39 (Davis & Suignard) whenever their canonical NFD confusable skeletons collide while mixing incompatible script extensions (such as Latin U+0061 a vs Cyrillic U+0430 а):
skeleton(X) = toNFD( map_confusable_prototypes( toNFD(X) ) )
is_spoof(X, Y) <==> (X != Y) && (skeleton(X) == skeleton(Y))3. Star-Height Ambiguity & Thompson (1968) Powerset Stepping
Patterns with nested repetition (star height >= 2, e.g. (a+)+$) or overlapping alternation inside loops ((a|aa)+$) exhibit exponential ambiguity degree on backtracking engines. Maintaining bitset state frontiers S_k subset {0..|P|-1} via Thompson’s construction bounds each input byte to O(|P|) transitions and total runtime to O(|P| * |S|).
4. Editorial & AppSec SaaS Consolidation Calculator
Compare separate writing, citation, SBOM, and security subscriptions against Destiny’s unified $0 Free tools and $14.99/mo Web Cloud Pass.
Add to LaTeX/GitHub READMEs, preprints, or lab docs after verifying DOIs, arXiv IDs & ISBN checksums.
Unicode UTS #39, Trojan Source & ReDoS Bounds — FAQ
Direct answers on UAX #9 BiDi override attacks, NFD confusable skeletons, Thompson linear-time NFAs, and zero-upload client-side scanning.
- How does CVE-2021-42574 (Trojan Source) hide malicious logic inside visually normal code or contracts?
- Boucher & Anderson (2021) demonstrated that Unicode bidirectional formatting code points (U+202A..U+202E LRE/RLE/PDF/LRO/RLO and U+2066..U+2069 LRI/RLI/FSI/PDI) reorder display glyphs independently of compiler or parser token order—making commented-out text render visually as active code or vice versa unless editors flag unbalanced BiDi scopes.
- How does the Unicode UTS #39 skeleton algorithm detect cross-script Cyrillic and Greek homoglyphs?
- Simple character blacklists miss composed accents and multi-character lookalikes. UTS #39 computes skeleton(X) = toNFD(replaceConfusables(toNFD(X))) using the Unicode confusables.txt prototype table and checks mixed-script identifier profiles (Identifier_Type and Script_Extensions) to catch CVE-2021-42694 identifier spoofing and IDN punycode phishing.
- Why do backtracking regex engines suffer O(2^n) ReDoS on nested quantifiers like (a+)+$, whereas Thompson NFAs run in O(|P| * |S|)?
- Recursive Spencer-style backtracking explores every partition of n repeated characters separately, doubling stack states per character on non-matching suffixes. Thompson (1968) simulation tracks the deduplicated set of active NFA states simultaneously (bounded by pattern size |P|), guaranteeing strict O(|P| * |S|) worst-case time.
- Can I scan text, code, and regex patterns for BiDi, homoglyphs, and ReDoS without uploading files?
- Yes. Open /tools/unicode-regex-forensics ($0, 100% browser-local execution) to inspect zero-width watermarks, CVE-2021-42574 BiDi overrides, mixed-script homoglyphs, and star-height ReDoS risk.