{"id":"XE-13106","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":2401,"title":"Recovery phrase: BIP39 passphrase NFKD is Unicode-version-skewed — Go and the JS tools silently derive different accounts for passphrases containing post-Unicode-15 characters","area":"sdk-docs-web","claimed_tier":"high","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T16:47:03.561602+00:00","updated_at":"2026-11-20T19:46:45.536261+00:00","source_created_at":null,"told_at":"2026-11-20T19:45:52.847980+00:00","status_changed_at":"2026-11-20T19:45:47.524745+00:00","url":"https://bounty.xe.network/XE-13106","body":"### Summary\n\nXE's recovery-phrase derivation applies NFKD to the BIP39 passphrase when building the\nPBKDF2 salt, but neither the spec nor the implementations pin a Unicode version, and the\nofficial implementations bundle different Unicode data. For any passphrase containing a\ncharacter that was assigned a decomposition mapping after Unicode 15.0, the Go CLI derives\na **different account** from the same phrase + passphrase + account index than the web\nwallet and the TypeScript SDK — silently, with no error on either side. 57 codepoints are\naffected today (listed below); the set is guaranteed to drift as Unicode and dependencies\nevolve.\n\n### Root cause\n\n`docs/recovery-phrase.md:13` specifies the BIP39 seed salt as `mnemonic` followed by\n`NFKD(BIP39 passphrase)`, with no Unicode version. The implementations resolve \"NFKD\"\nagainst different data:\n\n- Go: `core/recovery_phrase.go:99` computes the salt as\n  `\"mnemonic\" + norm.NFKD.String(passphrase)` using `golang.org/x/text` **v0.33.0**\n  (`go.mod:15`). That release's normalization tables are **Unicode 15.0.0** (the newest\n  tables file in the module is `unicode/norm/tables15.0.0.go`, `Version = \"15.0.0\"`).\n- Web wallet: `web/assets/recovery-phrase.js:71` uses `passphrase.normalize('NFKD')` —\n  the host browser engine's Unicode data (current engines ship Unicode 16/17 data).\n- SDK: `sdk/src/recovery-phrase.ts:76` delegates to `@scure/bip39`'s\n  `mnemonicToSeedSync`, which likewise uses the host engine's\n  `String.prototype.normalize`.\n\nA codepoint unassigned in Unicode 15.0.0 has no decomposition in Go's tables and is\npassed through unchanged; the same codepoint in a Unicode 17 engine is decomposed before\nthe salt is hashed. Different salt → different BIP39 seed → different SLIP-0010 leaf key\n→ different address.\n\n### Affected codepoints (57, exhaustive)\n\nVerified by comparing NFKD over **every** codepoint U+0000–U+10FFFF between\n`golang.org/x/text` v0.33.0 and a Unicode 17 engine (Node 24 / ICU 78.3; Bun's\nJavaScriptCore gives byte-identical results). These 57 are the complete current set —\nevery one is unassigned in Unicode 15.0.0 and assigned with a decomposition in\nUnicode 17.0.0 (checked against the official `UnicodeData.txt` of both versions):\n\n- U+A7F1 MODIFIER LETTER CAPITAL S — decomposes to `S`\n- U+105C9, U+105E4 (Todhri letters)\n- U+11383, U+11385, U+1138E, U+11391, U+113C5, U+113C7, U+113C8 (Tulu-Tigalari)\n- U+16121–U+16128 (Gurung Khema vowel signs)\n- U+16D68–U+16D6A (Kirat Rai vowel signs)\n- U+1CCD6–U+1CCF9 OUTLINED LATIN CAPITAL LETTER A–Z and OUTLINED DIGIT ZERO–NINE —\n  decompose to the corresponding ASCII `A`–`Z` / `0`–`9`\n\n### Reproduction (local, test vectors only)\n\nDifferential tester (attached) drives the real implementations: Go\n`core.KeyPairFromPhrase`, the web wallet's `seedFromPhrase` + `loadKeyPair`, and the\nSDK's `Wallet.fromPhrase`, all fed the fixture phrase\n`abandon` ×23 + `art` at account 0. One-command repro: run `repro.sh` from the attached\nPoC (builds the Go lane against the pinned clone, runs all three lanes).\n\n```\npassphrase = U+1CCD6 alone (OUTLINED LATIN CAPITAL LETTER A)\n  Go CLI core : a20534508ae1ae528983eb52c52c687ec207eaf840ba040707f8bcbc1ddfb04c\n  Web wallet  : c9efab74a3b507b2c47079e5d7d93bc39b4c728aca13338f557f12befe920853\n  SDK         : c9efab74a3b507b2c47079e5d7d93bc39b4c728aca13338f557f12befe920853\n\npassphrase = \"hunter2\" + U+1CCE9 (OUTLINED LATIN CAPITAL LETTER T)\n  Go CLI core : 60796a16848e5195224cd9bc242dbd29aea530bb8ff4c6d980c6e3dec8b6cb64\n  Web wallet  : ff14d7728478b845036f3768c1cf9f1e495d2cbbefa6903d741d493972199195\n  SDK         : ff14d7728478b845036f3768c1cf9f1e495d2cbbefa6903d741d493972199195\n\npassphrase = U+105C9 alone (TODHRI LETTER EI)\n  Go CLI core : f1964374bb9896ee7a1d5863cf607fab2e8503f2de4239ae1d6d986f0b693b35\n  Web wallet  : 6b2cbfa9ad3549e028495b611da331cbedd01632971e032333e4bbac1406b15c\n  SDK         : 6b2cbfa9ad3549e028495b611da331cbedd01632971e032333e4bbac1406b15c\n\ncontrol — passphrase = \"hunter2T\" (plain ASCII)\n  Go = Web = SDK = ff14d7728478b845036f3768c1cf9f1e495d2cbbefa6903d741d493972199195\n```\n\nAll 12 cluster representatives tested (outlined letters/digit, modifier S, Todhri ×2,\nTulu-Tigalari ×2, Gurung Khema ×2, Kirat Rai ×2) diverge identically; the control and a\n96-case cross-implementation matrix (accounts 0…2³¹−1, phrase lengths 12–24, ordinary\nUnicode passphrases) agree everywhere else.\n\n### Impact\n\n1. **Stranded funds on cross-tool restore.** A passphrase-protected wallet created in the\n   web wallet or via the SDK restores to an empty account in the Go CLI (and vice versa)\n   whenever the passphrase contains one of the 57 characters. Nothing reports an error;\n   the documentation's own warning that \"a wrong passphrase opens a different, empty\n   account\" (`docs/recovery-phrase.md:36`) leads the user to blame their backup.\n2. **Implementation-defined collisions.** Inside the JS tools, the passphrase\n   `hunter2` + U+1CCE9 opens the same account as `hunter2T` (see repro); in Go those are\n   two different accounts. Which backups collide depends on which tool derives them.\n3. **Structural drift.** Because the spec does not pin a Unicode version, every future\n   Unicode release, browser update, or `x/text` bump can silently move accounts for new\n   character sets, in either direction.\n\nReachability, stated plainly: the affected characters are new (Unicode 16, 2024;\nUnicode 17, 2025) and uncommon in passphrases today. The realistic carriers are a\npassphrase written in Todhri, Tulu-Tigalari, Gurung Khema or Kirat Rai — scripts encoded\nin Unicode 16 for living speaker communities — and outlined/\"fancy text\" characters\npasted into a passphrase. The bug is in the specification surface, not in any one\ncharacter: it will recur with new characters even if these 57 are special-cased.\n\nThe phrase path is not affected: the same characters inside a phrase word are rejected\nas unknown words by all three implementations (verified).\n\n### Suggested fix\n\nPin the normalization data in the spec and conformance vectors: state the Unicode\nversion of NFKD that derivation is defined against (e.g. \"NFKD as of Unicode 15.0.0\")\nin `docs/recovery-phrase.md`, ship shared test vectors whose passphrases contain\npost-15.0 characters for every implementation, and either (a) bring Go's `x/text` and\nthe JS guidance to that pinned version, or (b) reject, identically in all three\nimplementations, passphrase characters that are unassigned in the pinned version, so a\nbackup that derives in one tool can never silently derive differently in another.\n\n### Dedupe\n\n- **XE-6618** (web) and **XE-6994** (SDK): the U+0130 (İ) *lowercasing* difference makes\n  a *phrase* valid in the CLI and rejected in JS — a case-mapping difference in the\n  phrase path with a loud-rejection failure mode. This report is a *decomposition*\n  (NFKD) difference in the *passphrase* path whose failure mode is silent derivation of\n  a different key. Different primitive, different input surface, different failure mode;\n  both bodies were read in full.\n- Corpus sweeps (fresh desk corpus, 2,027 tickets, 2026-11-14): title greps for\n  `phrase|mnemonic|bip39|slip|deriv|seed|NFKD|normal|unicode|passphrase` and full-text\n  greps for `nfkd|decompos*|unicode version|x/text|outlined|todhri|tulu|gurung|kirat`\n  return no ticket about NFKD data versions or decomposition skew. Neighbours with\n  different mechanisms: XE-8556 (SDK rejects uppercase hex), XE-6895 (web malformed-hex\n  prefix parse), XE-10788 (CLI restore input handling), XE-12464 (hosted-wallet UI\n  checkbox), XE-0038 (CRLF wordlist bytes).","patch_refs":[],"thread":[{"id":3096,"source":"web","source_ref":"reporter:2401:65d0b0cbb9c2da4f","author":"xe:352fe8fc","team":false,"body":"Attachment packaging note: the desk caps a ticket at 5 attachments, so the PoC set was packaged as follows. Attached individually: repro.sh (the one-command reproduction), vectors2.json, go/main.go, js/web.mjs. The remaining manifest files are inside keys2-poc-bundle.tar.gz (attachment 5), which contains the complete PoC tree named in the report: gen_vectors2.py, go/go.mod, js/sdk.mjs, out/go2.jsonl, out/web2.jsonl, out/sdk2.jsonl, scan_diff.py, out/scan-go.tsv and out/scan-node.tsv, plus copies of the four individually attached files. All 13 manifest files are therefore on this ticket; every attachment's size was verified against the local originals after filing.","created_at":"2026-11-14T16:47:16.335249+00:00"},{"id":15287,"source":"desk","source_ref":"reply:13178","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read it against the code and it is being handled. We will update this ticket when there is news. https://bounty.xe.network/XE-13106","created_at":"2026-11-20T19:45:52.832697+00:00"}]}