From 0b83749aa1f67b516d3b40b26d2b44e7f8323d70 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Thu, 24 Sep 2026 19:36:24 +0700 Subject: [PATCH] cvm-server: only serve signature-verified events to agents (audit F2) queryNostr() previously returned every event the community data relays sent back, unverified. A malicious or buggy relay could inject forged coach profiles / listings that would flow straight into agents as trusted ground truth. Now each event is signature-verified with nostr-tools verifyEvent() before being returned; anything that fails (or throws) is dropped. Mirrors the client-side onlyVerified discipline already applied in the trust-score hooks. Co-authored-by: shakespeare.diy --- cvm-server/server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cvm-server/server.ts b/cvm-server/server.ts index 453edbc..0e3b8e3 100644 --- a/cvm-server/server.ts +++ b/cvm-server/server.ts @@ -22,7 +22,7 @@ import { ApplesauceRelayPool, } from "@contextvm/sdk"; import { z } from "zod"; -import { SimplePool } from "nostr-tools"; +import { SimplePool, verifyEvent } from "nostr-tools"; import type { Filter } from "nostr-tools"; // ─── Config ────────────────────────────────────────────────────────────────── @@ -60,7 +60,12 @@ async function queryNostr(filters: Filter[], timeoutMs = 8000): Promise { } }) ); - return allEvents; + // Audit F2 (server-side): only serve signature-verified events to agents. + // Unverified community-relay data must never become agent-trusted ground + // truth (forged coach profiles / listings would flow straight into agents). + return allEvents.filter((e) => { + try { return verifyEvent(e); } catch { return false; } + }); } // ─── Helpers ─────────────────────────────────────────────────────────────────