Skip to content
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

No validation for handle correspondence with DID, allowing malicious mentions #715

Open
lumi4x opened this issue Aug 2, 2024 · 1 comment

Comments

@lumi4x
Copy link

lumi4x commented Aug 2, 2024

I am able to mention what seems to be "@bsky.app", but in practice direct to a malicious handle like so:
image

This is caused by richtext facets allowing any text to be marked as a mention (or URL in another case).

Example code:

func (p *FeedPost) Mention(handle, did string) *FeedPost {
	byteStart := len(p.record.Text)
	p.record.Text += "@" + handle
	p.record.Facets = append(p.record.Facets, &bsky.RichtextFacet{
		Features: []*bsky.RichtextFacet_Features_Elem{
			{
				RichtextFacet_Mention: &bsky.RichtextFacet_Mention{
					LexiconTypeID: "app.bsky.richtext.facet#mention",
					Did:           did,
				},
			},
		},
		Index: &bsky.RichtextFacet_ByteSlice{
			ByteStart: int64(byteStart),
			ByteEnd:   int64(len(p.record.Text)),
		},
	})

	return p
}
@bnewbold
Copy link
Collaborator

bnewbold commented Aug 5, 2024

Yup! Thanks for the report.

As some context, the handle name in the mention and the DID in the facet are intentionally allowed to be mis-matched. The use-case for this is to have links (hyperlinks) continue to work if the account's handle is changed after the post is made.

Having a "new" post with a mismatch would mostly likely need to have been intentionally crafted to be misleading.

One possible mitigation for this would be to have the client detect the mismatch and re-write the post text, or display a warning. It is hard for clients to tell whether the change was intentionally misleading or due to a handle change.

A more likely mitigation is to scan new posts and indicate/label them as misleading if the handle doesn't match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants