Describe the bug
Kind 4 DMs and kind 1059 gift wraps are handed out to anyone who asks for them. We support NIP-42 AUTH but never actually check it on reads, so an unauthenticated client can just REQ for these kinds and pull down everyone's encrypted messages, ciphertext plus who-talks-to-who metadata. COUNT and live broadcasts leak the same way.
To Reproduce
- Run the relay (v3.0.0) with some users exchanging kind 4 / 1059 events.
- Connect without authenticating and send
["REQ", "sub", {"kinds": [4]}].
- You get back every user's DMs, including ones you're neither the author nor a
p recipient of.
COUNT and post-subscribe live events behave the same.
Expected behavior
Restricted kinds should only go to clients that have authenticated as the event author or a tagged p recipient. Needs to hold for REQ, live broadcasts, and COUNT.
COUNT can't be filtered per-event, so any COUNT touching a restricted kind has to be scoped to the caller's own pubkeys via authors/#p.
If a subscription only asks for restricted kinds and the client isn't authenticated, close it with auth-required: so the client knows to auth and retry, instead of silently returning nothing.
Describe the bug
Kind 4 DMs and kind 1059 gift wraps are handed out to anyone who asks for them. We support NIP-42 AUTH but never actually check it on reads, so an unauthenticated client can just
REQfor these kinds and pull down everyone's encrypted messages, ciphertext plus who-talks-to-who metadata. COUNT and live broadcasts leak the same way.To Reproduce
["REQ", "sub", {"kinds": [4]}].precipient of.COUNTand post-subscribe live events behave the same.Expected behavior
Restricted kinds should only go to clients that have authenticated as the event author or a tagged
precipient. Needs to hold for REQ, live broadcasts, and COUNT.COUNT can't be filtered per-event, so any COUNT touching a restricted kind has to be scoped to the caller's own pubkeys via
authors/#p.If a subscription only asks for restricted kinds and the client isn't authenticated, close it with
auth-required:so the client knows to auth and retry, instead of silently returning nothing.