Repository navigation
Commit 312014d
fix(relay): close NIP-98 HTTP bridge bypass in persona shared-gate
Apply the author-only-unless-shared read gate to the NIP-98 HTTP bridge
(/query, /count, search) and centralize the per-event visibility decision
into a single event_visible_to_reader helper callable from both WS and
HTTP adapters.
Bridge parity (CRITICAL):
- /query catchall: replaced the two-step is_author_only_event +
reader_authorized_for_event checks with event_visible_to_reader, which
also covers is_unshared_persona_event. A foreign authenticated caller
POSTing {kinds:[30175],authors:[victim]} or {ids:[unshared-id]} now
receives nothing.
- /count: added needs_persona_filtering to the fast-path guard (forces
fallback when the filter can match kind:30175) and replaced the two-step
checks in both fallback loops with event_visible_to_reader. Existence
leak via HTTP COUNT is closed on both the channel-scoped and unconstrained
paths.
- FTS search helper: replaced is_author_only_event with event_visible_to_reader
as defense-in-depth. Kind 30175 is not in the FTS allowlist today so the
branch is not reachable, but the check prevents a future allowlist change
from silently reopening the bypass (comment explains this at the site).
Structural centralization (IMPORTANT):
- Added event_visible_to_reader to handlers/req.rs, combining the three
per-event access predicates (is_author_only_event, is_unshared_persona_event,
reader_authorized_for_event) behind a single call. Both the WS and HTTP
adapters now call this helper at their result-visibility sites.
Test gaps closed (IMPORTANT):
- Reworked test_persona_live_fanout_shared_gate with explicit monotonic
created_at timestamps (t0 < t1 < t2) so NIP-33 head ordering is
deterministic, not dependent on event-id tie-break. Added self-query
assertions after each publish to verify the correct NIP-33 head is live,
and added a live-fan-out assertion that foreign receives nothing when the
shared head goes unshared.
- Added shared=x and missing-value wire-level rejection cases to
test_persona_ingest_shared_tag_validation (AC-5; previously only
shared=false and duplicate were tested at the wire level).
- Fixed test_persona_mixed_kind_filter_does_not_leak (AC-6): now publishes
a kind:9 event from the same author and asserts it IS returned while the
unshared persona is omitted. Previously the absence-only assertion would
pass if the whole mixed filter were dropped.
- Added two new HTTP bridge e2e tests:
test_persona_http_query_cross_author_gate: verifies /query returns only
shared persona to foreign, returns nothing for {ids:[unshared-id]}, and
returns the shared event for {ids:[shared-id]}.
test_persona_http_count_cross_author_gate: verifies /count returns 1
(shared only) to foreign and 3 (all) to author, on author-scoped and
wildcard filters.
NIP-AP.md (doc):
- Replaced aspirational every relay read chokepoint wording with an
enumerated list of gated surfaces including NIP-98 /query, /count, and
FTS/search with their exact enforcement mechanism named.
- Added Non-goal: side-band existence oracles note documenting the
adjudicated decision not to gate reaction/report/deletion target
resolution (leaks one bit of existence, never content; requires a known
event id unshared personas never hand out through any gated path).
Co-authored-by: Will Pfleger <[email protected]>
Signed-off-by: Will Pfleger <[email protected]>1 parent 01c7fc8 commit 312014d
4 files changed
Lines changed: 501 additions & 28 deletions
File tree
- crates
- buzz-relay/src
- api
- handlers
- buzz-test-client/tests
- docs/nips
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1284 | 1284 | | |
1285 | 1285 | | |
1286 | 1286 | | |
1287 | | - | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
1288 | 1291 | | |
| 1292 | + | |
1289 | 1293 | | |
1290 | 1294 | | |
1291 | 1295 | | |
1292 | 1296 | | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | 1297 | | |
1297 | 1298 | | |
1298 | 1299 | | |
| |||
1439 | 1440 | | |
1440 | 1441 | | |
1441 | 1442 | | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
1442 | 1448 | | |
1443 | 1449 | | |
1444 | 1450 | | |
| |||
1462 | 1468 | | |
1463 | 1469 | | |
1464 | 1470 | | |
| 1471 | + | |
1465 | 1472 | | |
1466 | 1473 | | |
1467 | 1474 | | |
| |||
1487 | 1494 | | |
1488 | 1495 | | |
1489 | 1496 | | |
1490 | | - | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
| 1497 | + | |
1495 | 1498 | | |
| 1499 | + | |
1496 | 1500 | | |
1497 | 1501 | | |
1498 | 1502 | | |
| |||
1526 | 1530 | | |
1527 | 1531 | | |
1528 | 1532 | | |
| 1533 | + | |
1529 | 1534 | | |
1530 | 1535 | | |
1531 | 1536 | | |
| |||
1551 | 1556 | | |
1552 | 1557 | | |
1553 | 1558 | | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
| 1559 | + | |
1559 | 1560 | | |
| 1561 | + | |
1560 | 1562 | | |
1561 | 1563 | | |
1562 | 1564 | | |
| |||
1732 | 1734 | | |
1733 | 1735 | | |
1734 | 1736 | | |
1735 | | - | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
1736 | 1749 | | |
1737 | 1750 | | |
1738 | 1751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1215 | 1215 | | |
1216 | 1216 | | |
1217 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
1218 | 1252 | | |
1219 | 1253 | | |
1220 | 1254 | | |
| |||
0 commit comments