fix(sdk,desktop): keep self-targeted p tags on membership and PR status events - #3384
Open
shrimalmadhur wants to merge 1 commit into
Open
fix(sdk,desktop): keep self-targeted p tags on membership and PR status events#3384shrimalmadhur wants to merge 1 commit into
shrimalmadhur wants to merge 1 commit into
Conversation
nostr 0.44's `EventBuilder` silently strips any `p` tag whose value matches
the signing pubkey unless the builder opts in via `.allow_self_tagging()`.
Buzz treats `p` tags as protocol routing data, not a self-notify privacy
scrub, so several builders whose target can legitimately be the signer were
shipping events with the target missing.
Two concrete failures:
- kind 9000/9001 self-add and self-remove are first-class relay paths
("Self-add: always allowed regardless of policy", pinned by
`test_nip29_put_user_self_add_bypasses_policy`), but neither SDK nor
desktop builder could express them — the relay saw no target and rejected
with `invalid: missing p tag`.
- `build_merged_status_event` / `build_pull_request_status_event` derive
`owner` from the signing key and then p-tag it, so *every* PR lifecycle
event (kinds 1630-1633) shipped without its owner `p` tag. This one is
silent: readers index those events by `#p` as `recipients`, so the owner
just quietly vanished from the participant set.
Existing tests sign with a key distinct from the target, so they passed
either way. The added regression tests sign with the target's own key and
assert the `p` tag survives; each was confirmed to fail before the fix.
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Madhur Shrimal <642275+shrimalmadhur@users.noreply.github.com>
p tags on membership and PR status events
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.
Summary
nostr 0.44's
EventBuildersilently strips anyptag whose value matches the signing pubkey unless the builder opts in via.allow_self_tagging(). Buzz treatsptags as protocol routing data, not a self-notify privacy scrub, so several builders whose target can legitimately be the signer were shipping events with the target missing.Two concrete failures:
side_effects.rsreads// Self-add: always allowed regardless of policy, pinned bytest_nip29_put_user_self_add_bypasses_policy("an agent can always add itself"). But neither the SDK nor the desktop builder could express them: theptag naming the signer was stripped, so the relay saw no target and rejected withinvalid: missing p tag. The misleading error made this look like an authorization failure.build_merged_status_event/build_pull_request_status_eventderiveownerfrom the signing key and then p-tag it, soowner == signerby construction and kinds 1630–1633 always shipped without["p", owner]. No error — readers index those events by#pasrecipients(projectPullRequests.mjs), so the owner just quietly vanished from the participant set.Root cause is historical:
.allow_self_tagging()arrived with NIP-IA (#733) and was later added to the kind:9000 e2e test (#3017), but never to the shipped builders. Every self-targeted test hand-rolls its ownEventBuilderto work around it.Related issue
None found — searched existing issues and PRs; nothing covers the self-tag stripping behavior.
Testing
cargo fmt --all --checkand clippy (-D warnings, bothbuzz-sdkand the desktop Tauri crate) are clean. 243/243buzz-sdkand 1820/1820 desktop Tauri unit tests pass. The ~9buzz-relayfailures reproduce identically on a stashed clean tree — pre-existing, infra-dependent media/admin tests, unrelated to this change.The five added regression tests are the point of the change: existing tests sign with a key distinct from the target, so they passed either way and this survived CI. The new ones sign with the target's own key and assert the
ptag survives. Each was confirmed to fail before the fix and pass after:No UI change, so no screenshots. Verification is at the wire-form level — the live relay e2e suite needs Postgres/Redis and was not run.
Not addressed here
The same hazard remains in ~15 other
p-emitting builders, deliberately scoped out because they change discovery/notification semantics and deserve their own review: note-to-self DMs (build_dm_open— currently unimplementable, fails aspubkeys must contain at least 1 other participant), the git SDK builders (issue/status/PR/patch, where the CLI defaults recipients to the repo owner), the desktopsign_eventTauri passthrough, and self-mentions/self-follows.There is no single signing chokepoint that would fix this globally —
buzz-clihas one (client.rs:588), but the desktop signs in ~50 scattered places. A lint or shared signing helper is probably worth considering so the next builder doesn't reintroduce it.Co-Authored-By: SageOx <ox@sageox.ai>