Repository navigation
fix(id): use UTS #39 petname skeletons #4268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
...ble_skeleton/2026-11-02T12-47-00Z_design_petname_unicode_confusable_skeleton.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Petname anti-mimicry: Unicode UTS #39 confusable skeleton | ||
|
|
||
| - **Date:** 2026-11-02T12-47-00Z | ||
| - **Kind:** design | ||
| - **Issue:** developing-today/code#2899 (follow-ups to #2069 and #1674) | ||
| - **Code:** `pkgs/id/crates/id-core/src/petname.rs` (`skeleton()`), PR #4268 | ||
|
|
||
| ## Problem | ||
|
|
||
| Petnames are a trust surface: a contact's petname is how the owner recognizes | ||
| who they are talking to, so `Petnames::set` refuses a new petname that is | ||
| confusable with an existing petname or an alleged name. Until now the | ||
| confusability check was a handwritten ASCII skeleton in `skeleton()`: | ||
|
|
||
| - `fold()` strips Cf format characters (#1674) and lowercases; | ||
| - `skeleton()` then mapped a fixed set of ASCII look-alikes (`0`/`o`, | ||
| `1`/`|`/`i`/`l`, `8`/`b`, ...; the `I`/`8` additions are #2069). | ||
|
|
||
| That map cannot enumerate cross-script homoglyphs. Verified on main before | ||
| this change: Cyrillic U+0430/U+0410/U+043E/U+0435/U+0421 and Greek U+03BF | ||
| pairs (e.g. Latin `PayPal` vs Cyrillic-а `Pаypal`) produced different folds | ||
| and different skeletons, so `set()` accepted them — a spoof petname needed | ||
| no invisible characters to defeat the guard. `labels()` keys collision | ||
| fingerprints by the same skeleton, so legacy cross-script collisions also | ||
| went unfingerprinted. | ||
|
|
||
| ## Decision | ||
|
|
||
| `skeleton()` now computes, in order: | ||
|
|
||
| 1. `fold(name)` — strip Cf format characters, lowercase (unchanged, #1674). | ||
| 2. The Unicode UTS #39 confusable skeleton of the folded name, via the | ||
| `unicode-security` crate (v0.1.3, `unicode_security::skeleton`). | ||
| 3. `fold()` again over the skeleton output, so any case/format characters | ||
| the skeleton mapping introduces are normalized the same way as input. | ||
| 4. The existing petname-specific ASCII look-alike map, unchanged. | ||
|
|
||
| Both comparison paths consume this one function — `Petnames::set` (against | ||
| existing petnames and alleged names) and `labels()` collision keying — so | ||
| legacy cross-script collisions receive fingerprints from the same skeleton | ||
| that now refuses new ones. | ||
|
|
||
| ## Rationale and alternatives | ||
|
|
||
| - **UTS #39 skeleton, not a bigger handwritten map.** The confusable table | ||
| is a maintained Unicode data set covering Cyrillic, Greek, and the other | ||
| scripts; a hand-maintained map is what left the cross-script hole after | ||
| two rounds of ASCII additions (#2069, #1674). | ||
| - **ASCII map retained, applied after the Unicode skeleton.** UTS #39 does | ||
| not treat leet-style digit/letter pairs (`1`/`l`, `0`/`o`, `8`/`b`, | ||
| `rn`/`m`) as confusable, and existing behavior depends on them | ||
| (`PayPa1`/`rnurn` controls). Dropping the map would regress #2069. | ||
| - **Folding order: fold before and after.** Lowercasing first puts capital | ||
| look-alikes into the classes the skeleton data expects; folding the | ||
| skeleton output keeps the pipeline idempotent in case/format handling. | ||
| - **Rejected: blanket rejection of non-Latin names.** Petnames legitimately | ||
| exist in other scripts; a single-script Cyrillic name (e.g. `Иван`) must | ||
| stay accepted. The skeleton only makes cross-script *look-alikes of an | ||
| existing name* collide; unrelated names in any script are unaffected. | ||
| - **Rejected: mixed-script rejection alone.** It misses same-name spoofs | ||
| written with homoglyphs and rejects legitimate mixed-script names that | ||
| mimic nothing when used as the sole test. | ||
|
|
||
| ## Compatibility | ||
|
|
||
| - Names previously accepted keep the same skeleton unless they are | ||
| UTS #39-confusable with another name — in which case the pair was a | ||
| spoofing hazard by definition. Single-script non-Latin names and | ||
| unrelated names are unchanged. | ||
| - `labels()` fingerprints: pairs that previously shared no skeleton key | ||
| (cross-script collisions already stored) now key together and receive | ||
| distinguishing fingerprints, which is the intended disclosure behavior. | ||
|
|
||
| ## Verification | ||
|
|
||
| Regression tests in `petname.rs` (`test_` prefix per pkgs/id/AGENTS.md): | ||
|
|
||
| - six Cyrillic/Greek homoglyph pairs refused against both an existing | ||
| petname and an alleged name; | ||
| - ASCII controls (`PayPa1`, `rnurn`, `M0m`) still refused; | ||
| - unrelated names and a single-script Cyrillic name accepted; | ||
| - legacy cross-script petname collisions get distinct `labels()` | ||
| fingerprints. | ||
|
|
||
| Run: `cargo test --lib petname` in `pkgs/id`. | ||
|
|
||
| --- | ||
|
|
||
| ## 2026-11-02T12-47-00Z Decision: record added with the change | ||
|
|
||
| This record is filed in the same PR as the implementation (PR #4268) per | ||
| the pkgs/id documentation protocol; the pipeline above is the policy the | ||
| shipped code implements, with no deviations. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing the handwritten skeleton with Unicode normalization changes which petnames are accepted and which existing names receive collision fingerprints. This also introduces policy choices about folding order and retaining custom ASCII equivalences, but the commit contains no dated design record. A repository-wide Markdown search found only the original petnames design describing the handwritten mapping. Add the dated document required by
pkgs/id/AGENTS.md, explaining the normalization pipeline, its rationale, and compatibility with existing names.AGENTS.md reference: pkgs/id/AGENTS.md:L159-L168
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in f587378: added the dated design record required by pkgs/id/AGENTS.md at doc/2026-11-02T12-47-00Z_design_petname_unicode_confusable_skeleton/2026-11-02T12-47-00Z_design_petname_unicode_confusable_skeleton.md. It documents the normalization pipeline (fold -> UTS #39 skeleton via unicode-security 0.1.3 -> fold -> retained petname ASCII map), the folding-order rationale, why the ASCII equivalences are kept (#2069), compatibility for existing names (single-script non-Latin names such as a Cyrillic name stay accepted; no blanket or mixed-script rejection), and the labels() fingerprint effect for legacy cross-script collisions.