Repository navigation
In review
Description
What happened
Events received over a peering feed are written with the bulk-import persister, which skips the admission checks the normal EVENT path performs. A configured peer can therefore push content the relay would reject if a client published it directly.
Relay version
3.17.1
Deployment
docker compose
OS
Linux
NIPs involved
No response
Logs
## Affected code
- `src/app/peering-sync-worker.ts:187` — `createEventBatchPersister(...)`
- `src/services/event-import-service.ts:136+` — `createEventBatchPersister`
- For contrast: `src/handlers/event-message-handler.ts` (PoW, size, created_at, blocklist, NIP-05, spam checks)
## Why it's wrong
The sync worker persists through the import path:
this.persistEvents = createEventBatchPersister(eventRepository, {
userRepository: options.userRepository,
relayUrl: settings().info?.relay_url,
})
`createEventBatchPersister` applies vanish/delete semantics and drops ephemerals, but none of the write policy: minimum PoW, content and tag limits, `created_at` bounds, blocked/banned pubkeys, NIP-05 or whitelist gating.
`acceptEvents` does verify shape, scope, expiry, event id and signature — that is *transport* validation, not *policy* validation. Live feed events are then rebroadcast to local subscribers (`broadcastEvent`), so the bypass is visible to readers, not just to storage.Reproduction steps
- Configure a peer scope that covers kind 1.
- On the peer, publish a kind-1 event from a pubkey on the receiving relay's blocklist (or below
minPowDifficulty, or over the content limit). - The receiving relay stores and broadcasts it.
- Publish the same event directly to the receiving relay — it is rejected.
Additional context
Impact
Moderation and admission settings do not apply to peering traffic. Operators who configure blocklists, PoW floors or content limits will reasonably assume they cover all writes.
Proposed fix
Extract the admission decision out of EventMessageHandler into a shared admitEvent(event, context) and call it from the sync worker before persistEvents. Keep the batch persister for the historical backfill path only, where skipping policy is intentional.
For whoever picks this up
- What is wrong: Events a configured peer sends over a peering feed are written with the bulk-import persister and then rebroadcast to local subscribers, without the admission policy the normal EVENT path applies, so a peer can store and fan out events from blocked pubkeys, below the PoW floor, or over the content and tag limits that a local client would be refused for.
- Done looks like: the live feed path applies the same admission decision as
EventMessageHandler.handleMessage()beforepersistEvents, so a live event that violates the receiving relay's policy is neither stored nor broadcast, while the historical backfill keeps the policy-free batch persister. Addit('refuses a live peering event that the local admission policy rejects')totest/unit/app/peering-sync-worker.spec.ts: offer a live event over the configured content limit (or from a blocked pubkey) and assertlocalEventsdoes not gain it; it fails today becausePeeringPeerSession.acceptEvents()persists it. A second case should assert an event inside the limits is still stored, so the gate is not a blanket refusal. - Where it lives:
src/app/peering-sync-worker.ts—PeeringPeerSession.acceptEvents(), which persists through thecreateEventBatchPersisterbuilt in the session constructor and rebroadcasts live writes; the checks to share areEventMessageHandler.handleMessage(),isEventValid(),canAcceptEvent(),isBlockedByRequestToVanish(),isUserAdmitted()andcheckNip05Verification()insrc/handlers/event-message-handler.ts. The persister iscreateEventBatchPersister()insrc/services/event-import-service.ts. All onmain(943fd7a); the Rust tree has peering identity only and no feed-sync code, so this fix and its tests land in the TypeScript tree. - Intent: Relay peering: advertise terms in NIP-11, authenticate peers, handle feeds distinctly from clients #931 — peering keeps operator-configured admission and moderation in force for what the relay stores, so a peer feed must not become a hole in those settings.
Activity
chappie-daemon commentedon Dec 6, 2026
Delivery date: Friday 2026-12-18.
A PR that is green and ready for review by then keeps this row yours. If nothing is up by Monday 2026-12-21 we take the row back into our own queue, because the v4 cutover on 2026-12-31 cannot wait on it.
Your PR #1417 is already up, so this is a checkpoint rather than a start.
If that date does not work, say so here and we will set one — a stated date is only useful if it is one you can meet.