Skip to content

fix(workflows): resolve verified profile mention aliases - #9624

Closed
cshtdd wants to merge 2 commits into
block:mainfrom
cshtdd:camilos/fix-workflow-verified-mentions
Closed

cshtdd wants to merge 2 commits into
block:mainfrom
cshtdd:camilos/fix-workflow-verified-mentions

Conversation

@cshtdd

@cshtdd cshtdd commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Fix missing mention recipients in workflow messages for members who have only a relay-verified profile.

For example, Alex is a channel member whose verified profile shows Alex Example (@alex), but who has no ordinary profile. A workflow sends Reminder @alex: post your update:

  • Before: The message contains @alex, but Alex is missing from its recipient (p) tags. The text looks like a mention without actually tagging Alex.
  • After: The same message includes Alex's recipient tag, without requiring Alex to create a separate ordinary profile.

The lookup previously used only ordinary profile names. Include verified display names, usernames and full names too. Keep the existing channel/community boundaries, reject ambiguous names and preserve agent-wake authority checks.

Related issue

Related: #9340 optimizes the ordinary-profile lookup but does not add verified aliases.

Generated with Amp

Signed-off-by: Camilo Sanchez <camilos@squareup.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1eab0-97d0-75be-af34-a93d1ee350c1
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 44e97e96f43b3882151119ed59f0af4c2fb4fbad...abbb55cef35dbfcacca1b497bf7e2bb349f2ac94
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete findings in the authorized PR range. Verified-profile aliases remain community-scoped and restricted to active channel members, with existing ambiguity and workflow-authority checks preserved.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source inspection. Builds and tests were not run.

Generated by Codex Security Review |
Requested by: @cshtdd |
Workflow run

@cshtdd

cshtdd commented Nov 17, 2026

Copy link
Copy Markdown
Author

No description provided.

@cshtdd

cshtdd commented Nov 17, 2026

Copy link
Copy Markdown
Author

@builderbot review

Amp-Thread-ID: T-01a1eab0-97d0-75be-af34-a93d1ee350c1
Signed-off-by: Camilo Sanchez <camilos@squareup.com>
@cshtdd

cshtdd commented Nov 17, 2026

Copy link
Copy Markdown
Author

No description provided.

@cshtdd

cshtdd commented Nov 17, 2026

Copy link
Copy Markdown
Author

@builderbot review

@cshtdd
cshtdd marked this pull request as ready for review November 17, 2026 23:06
@cshtdd
cshtdd requested a review from a team as a code owner November 17, 2026 23:06

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 This is a comment, not an approval. A human maintainer must review this PR before it can merge.

I read the diff against main and traced the verified-profile code paths. I did not run the tests: the Rust CI jobs have not run on this PR yet.

What looks right

  • A "verified profile alias" is the display_name, username or full_name tag of the relay-signed kind 30382 head in nip_fi_profile_heads. It is written only after an issuer assertion is checked on a human WebSocket admission, for the key proven by NIP-42. A user cannot claim another user's alias by editing their own kind:0, because that table is never fed from kind:0.
  • The query is scoped to the community and joined only to the destination channel's member keys, so non-members and other communities do not match. The tests cover both.
  • Ambiguity is kept: every (name, key) pair goes into the existing map, and a name shared by two keys resolves to nobody. The ordinary-vs-verified collision is tested.
  • Authority is unchanged. The buzz:workflow-mention tag is still only added when the name resolves from the owner's authored template, so text injected through trigger.text gets a p tag but no agent wake. This is tested.

Findings

  • P2: These tables are documented as output-only ("Authorization never reads these tables", top of store/verified_profiles.rs). Workflow mention resolution now reads them, and that resolution decides who receives buzz:workflow-mention. The wake gate still holds, but the doc comment is now wrong. Please update it or say why this use is safe.
  • P2: Verified heads are never retracted, and the active tag is always true, so aliases are only as fresh as the holder's last admission. If an issuer reuses a username, the old holder keeps a stale alias. While both are channel members the mention is silently dropped. If only the old holder is in the channel, they are notified in place of the new holder. A bounded age check on verified_at, or a note that this is accepted, would help.
  • P2: Any channel member can set an ordinary display name equal to someone's verified username or full name. That makes the alias ambiguous and silently drops the mention. It cannot redirect the mention to the attacker, and ordinary names already behave this way. But verified names now look trustworthy, and a workflow can start missing a person with no error. Consider a log line when a mention is dropped as ambiguous.
  • P3: Matching only uses to_lowercase, with no Unicode normalization. A composed name in the issuer profile and a decomposed name typed in the template will not match. This fails closed, so it is only a missing notification.
  • P3: The new test covers lowercase aliases only. Add a mixed-case alias such as @ALEX, and a case where two verified heads share a username, to pin the behavior. Also the doc comment on resolve_mention_pubkeys has a line that runs past the usual wrap width.

names.push((name, pubkey.clone()));
}
let profile: Option<sqlx::types::Json<nostr::Event>> = row.try_get("event")?;
if let Some(profile) = profile {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 P2: The head is read as stored, with no check of verified_at or active. Heads are never retracted, so a stale alias can still resolve. Please add an age bound or note that it is accepted.

let named_members = state
.db
.get_users_bulk_for_event_write(tenant.community(), &member_pubkeys)
.get_mention_names_for_event_write(tenant.community(), &member_pubkeys)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 P2: This lookup now feeds the same resolver that produces buzz:workflow-mention. store/verified_profiles.rs says authorization never reads these tables. Please update that doc or explain why this is safe.

Comment thread AGENTS.md
[evalexpr](https://docs.rs/evalexpr) for condition evaluation. Keep expressions
simple and testable.

Workflow mention candidates include ordinary display names and verified

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 P2: Worth adding that a member's ordinary display name can collide with a verified alias and make it ambiguous, so the mention is dropped silently.

@kazemek21

Copy link
Copy Markdown
Contributor

Instructions to get the build to run:
buzz://message?channel=5909b3f1-fbe6-4f63-9cd2-06440e58b4a1&id=41538c84fc77a64cc0d124407b31805e3d485d331654a91b5185d62dc9245b05&thread=71a8d710754540d5c562226840389021badb3398752eb76d821d2a5b6c2b16ba

@cshtdd

cshtdd commented Nov 18, 2026

Copy link
Copy Markdown
Author

@buzz-security-review abbb55c

@cshtdd

cshtdd commented Nov 19, 2026

Copy link
Copy Markdown
Author

🤖 Superseded by #9685. The replacement is a draft on an upstream branch. Review comments were copied there with attribution and links to the originals.

@cshtdd cshtdd closed this Nov 19, 2026
damienrj added a commit that referenced this pull request Nov 19, 2026
## Summary

`buzz users get` reads only kind:0 profiles, so the CLI can't find or
confirm a person by their verified username. This adds relay-verified
profiles (kind:30382) to `users get`.

- `--pubkey` adds a `verified` object (`username`, `display_name`,
`full_name`, `issuer_label`, `verified_at`) for subjects that have one.
A requested person with a verified profile but no kind:0 is still
returned.
- `--name` uses the relay's `POST /profiles/search` when the community
advertises verified profiles with `searchable: true`, so it matches
verified names (word prefix). Otherwise, or for queries over the
endpoint's 100-character limit, it runs the existing NIP-50 substring
search and attaches verified profiles where the community advertises
them.

Verified profiles are read only when NIP-11 advertises
`federated_identity.public_profile`. A projection is trusted only if it
is kind 30382, signed by the relay's `self` key with a valid signature,
and follows the NIP-FI projection rules the mobile client applies: empty
content, exactly the projection tags (each once with one value), `p`
equal to `d`, `active` set to `true`, a valid username, names of 1–64
characters with no surrounding whitespace or control characters (looser
than mobile, which also requires NFC and rejects more Unicode
categories), and a decimal `verified_at` no later than `created_at`. The
newest projection per subject wins (the lower id breaks a same-second
tie), so a retraction clears the verified name. Any `verified` key in
user-authored kind:0 content is dropped on every path, so only a
relay-signed projection can set it.

`users get` now makes one NIP-11 request. If that request fails, the
advertisement is malformed, or the kind:30382 lookup fails, it still
prints the kind:0 results and writes a `verified_profiles_unavailable`
warning to stderr. This applies to `--pubkey`, no args, and `--name`.

### Related issue

Related: #8745 (verified profile spec), #9624 (verified-name mentions in
workflows).

### Testing

- `cargo test -p buzz-cli` passes, with tests for trust checks,
retraction, both lookup paths, search without the advertisement, and a
forged `verified` object in kind:0 (no advertisement, impostor-only
projection, and a valid projection replacing it).
- `cargo fmt` and `cargo clippy -p buzz-cli -D warnings` are clean.
- An earlier revision of the built CLI was run against a live community
with verified profiles: `--name <verified username>` found a user whose
kind:0 name differs, and `--pubkey` returned the expected `verified`
objects.

---------

Signed-off-by: damienrj <damien@squareup.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants