Repository navigation
fix(cli): normalize the pubkey a moderation action is keyed on - #5963
Closed
chessing234 wants to merge 2 commits into
Closed
chessing234 wants to merge 2 commits into
chessing234 wants to merge 2 commits into
Conversation
`validate_hex64` is documented as validating a "64-character lowercase hex string" but accepts either case — `is_ascii_hexdigit` does. Every caller then passes the string through unchanged. Hex is case-insensitive to a human and byte-exact to a relay: a filter for `#p` `abc…` does not match a tag holding `ABC…`. Add `parse_hex64`, which validates and returns the value lowercased, for callers that put the string on the wire, and correct the older function's doc to say what it does. No call sites yet. Signed-off-by: Taksh <takshkothari09@gmail.com>
`buzz moderation ban <pubkey>` validated the hex and then published it verbatim. Paste a pubkey in uppercase — from a block explorer, a log line, a colleague's message — and the ban goes out as `["p", "ABC…"]`. Nothing resolves that to the person. Relays match tag values byte for byte, and every other producer in the tree lowercases (`normalizeMentionPubkeys`, the desktop's `normalizePubkey`), so the ban is published, acknowledged, and silently applies to nobody. Unban, timeout, untimeout and report resolution all share the shape. Take the lowercased value from `parse_hex64` instead. A pubkey that was already lowercase is unaffected. The other ~55 `validate_hex64` call sites have the same latent gap; this one is separable and its failure mode — a moderation action that reports success and does nothing — is the worst of them. Signed-off-by: Taksh <takshkothari09@gmail.com>
Contributor
Author
|
closing this — i was wrong. the underlying gap is real, just one layer over: the cli builds some nip-01 filters as raw json, and generic tag filters ( |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Found by reading
validate_hex64against its own doc comment; no issue filed.buzz moderation ban <pubkey>validates the hex and then publishes it verbatim. Paste a pubkey in uppercase — from a block explorer, a log line, a colleague's message — and the ban goes out as["p", "ABC…"].Nothing resolves that to the person. Relays match tag values byte for byte (
filter_match_onecomparesevent_val == filter_val), and every other producer in the tree lowercases —normalizeMentionPubkeysin the desktop'sthreading.ts,normalizePubkeyinshared/lib/pubkey.ts. So the ban is published, acknowledged, printed as success, and applies to nobody.unban,timeout,untimeoutand report resolution all share the shape.validate_hex64's doc says it validates a "64-character lowercase hex string", butis_ascii_hexdigitaccepts either case and no caller normalizes. The first commit addsparse_hex64— validate, then return the value lowercased — and corrects that doc to say what the function actually does. The second uses it inmoderation.rs. A pubkey that was already lowercase is unaffected.Scope. There are ~55 other
validate_hex64call sites with the same latent gap, across issues, PRs, patches, reactions and social. They're separable, and each needs its own look at whether the value ends up in a tag, a URL path, or only a local comparison — I didn't want to sweep 14 files blind. Moderation is the one where the failure mode is worst: a command that reports success and silently does nothing.Verified locally on the pinned 1.95.0 toolchain:
cargo test -p buzz-cli— 352 passed, 0 failed (349 before, plus the 3 new)cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanNote: I'm an outside contributor, so the workflow runs here sit at
action_requireduntil a maintainer approves them; only the DCO check reports on its own.