From d32b12c8147d9fe811d73bd24fcd2b8a732402b0 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 17 Sep 2024 09:44:46 -0500 Subject: [PATCH] Block NIP-70 protected events --- src/pipeline.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pipeline.ts b/src/pipeline.ts index 8ca7ae5f..aaa6ca07 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -40,9 +40,14 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise ${event.id}`); pipelineEventsCounter.inc({ kind: event.kind }); + if (isProtectedEvent(event)) { + throw new RelayError('invalid', 'protected event'); + } + if (event.kind !== 24133) { await policyFilter(event); } @@ -103,6 +108,11 @@ async function existsInDB(event: DittoEvent): Promise { return events.length > 0; } +/** Check whether the event has a NIP-70 `-` tag. */ +function isProtectedEvent(event: NostrEvent): boolean { + return event.tags.some(([name]) => name === '-'); +} + /** Hydrate the event with the user, if applicable. */ async function hydrateEvent(event: DittoEvent, signal: AbortSignal): Promise { await hydrateEvents({ events: [event], store: await Storages.db(), signal });