GeezerVison is showing github.com — id(local_claims): hex_bytes is the one pkgs/id hex parser the #2517 gate missed — it panics on misaligned multi-byte input and accepts '+'-pair spellings · Issue #7750 · developing-today/code
id(local_claims): hex_bytes is the one pkgs/id hex parser the #2517 gate missed — it panics on misaligned multi-byte input and accepts '+'-pair spellings #7750DescriptionSummary
pkgs/id/src/local_claims.rs's private hex_bytes (lines 247–257) is the one hex parser in pkgs/id that the #2517/#3457 hardening missed: it has no ASCII-hexdigit gate and decodes by slicing &text[index..index + 2] at byte offsets. Two consequences, both verified this run on main 4af4ee8354:
- Panic instead of the designed error. A
local-claims.jsonl line whose id/author/subject field has even byte length but contains a multi-byte character at a misaligned offset panics with byte index 2 is not a char boundary instead of returning the function's "{text:?} is not hex" error. LocalClaims::open (local_claims.rs:69–97) is explicitly built to turn a malformed line into an InvalidData io error naming the file and line number; the panic escapes that handling and crashes the caller (LocalEvents open at local_events.rs:233) on a corrupt/hand-edited/sync-mangled claims file.
- Non-canonical
+ spellings accepted. u8::from_str_radix accepts a leading +, so "+a" decodes as 0x0a — exactly the dual-spelling problem id(directory/auth): hex_to_array and hex_bytes accept '+'-encoded pairs — the same key/signature has two spellings, and a signed request's replay-guard id can be re-encoded #2517 fixed in directory.rs::hex_to_array and directory_auth.rs::hex_bytes, and that invites/invitation.rs::parse_hex32 and seitan/derive.rs::InviteId::from_hex also gate against. Every sibling parser gates on bytes().all(|b| b.is_ascii_hexdigit()) first; this one does not.
Evidence
pkgs/id/src/local_claims.rs:247-257 — ungated slicing decoder (only guard is an even-length check).
- Sibling gates for comparison:
pkgs/id/src/directory.rs:2597-2610, pkgs/id/src/directory_auth.rs:370-385, pkgs/id/src/invites/invitation.rs:124-135, pkgs/id/src/seitan/derive.rs:66-76.
- Probe (laptop,
~/git/fleet/probe-localclaims-hex, exact copy of the function, main 4af4ee8354):
hex_bytes(&"0a".repeat(32)) → Ok([10, …]) (control)
hex_bytes(&"zz".repeat(32)) → Err("… is not hex") (control)
hex_bytes(&"+a".repeat(32)) → Ok([10, …]) (non-canonical spelling accepted)
hex_bytes("€a") (4 bytes, even) → PANIC end byte index 2 is not a char boundary; it is inside '€' (bytes 0..3)
Why it matters
The claims file is on-disk state read at open time; robustness there is the difference between a named, line-numbered error and an unexplained crash. The missing gate is also a consistency hole in a hardening pass (#2517/#3457) that was supposed to cover the repo's hex decoders.
Acceptance criteria
Activitydeveloping-today commented on Nov 8, 2026 dezren39 commented on Nov 8, 2026 Filed this run by the new-issue-creator (lane A) after verification on the laptop against main 4af4ee8354 (probe ~/git/fleet/probe-localclaims-hex: exact copy of the function — €a input panics at the char boundary, +a pairs decode as 0x0a, valid/ASCII controls behave). Self-assigning for a guarded trivial self-solve under lifecycle protocol §4: the fix mirrors the existing #2517 ASCII gate used by the sibling parsers in directory.rs / directory_auth.rs, plus byte-chunk decoding and regression tests.
dezren39 commented on Nov 8, 2026 Self-solve complete: PR #7757 merged as 4834a3e050bc (squash). Fix gates hex_bytes on ASCII hexdigits and decodes from byte chunks; regression test covers plus pairs, misaligned multi-byte input, valid uppercase, odd length and non-hex. Verified on the laptop before merge: cargo test -p id --lib local_claims — 9 passed, 0 failed. No queue packet (§4 self-solve).
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|