• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cameri / nostream / 44396771360
80%

Build:
DEFAULT BRANCH: main
Ran 18 Nov 2026 09:03PM UTC
Jobs 2
Files 339
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

18 Nov 2026 08:59PM UTC coverage: 79.245% (+0.003%) from 79.242%
44396771360

push

github

web-flow
fix(nip42): require auth to COUNT a filter that names no kinds (#1160)

## Description
With `nip42.restrictedReads` enabled, `isCountAuthorized` only looked at
COUNT filters that **named** a restricted kind (for example 4 or 1059)
and required those to be scoped with `authors` or `#p` to the client's
own authenticated pubkeys. A filter that named **no kinds** skipped the
check, but `countByFilters` still counts every kind for it, restricted
events included. So an unauthenticated client could send `["COUNT", "q",
{"#p": ["<pubkey>"]}]` and learn how many private messages (kind 4) or
gift wraps (kind 1059) were addressed to that pubkey. REQ hides
restricted events one by one, and COUNT cannot, which is why the scoping
rule exists.

- a COUNT filter that names no kinds is now treated like one that names
a restricted kind: it has to be scoped with `authors` or `#p` to the
authenticated client's pubkeys, or the request is closed with
`auth-required`;
- this is the rule NIP-77 reconciliation already uses
(`isReconciliationAuthorized`). Both now share one helper,
`mayMatchRestrictedKind`, so they cannot drift apart again;
- `kinds: []` still matches nothing (the repository does
`whereIn('event_kind', [])`), so it stays allowed.

Who is affected: only relays that turn on `nip42.restrictedReads`; it is
off by default. For them, a COUNT without `kinds` and without an
`authors`/`#p` scope is now refused. A COUNT that names ordinary kinds
(for example `{"kinds": [3], "#p": [...]}` for follower counts) is
unchanged.

## Related Issue
Partly addresses #1020 (finding F-028). That issue groups six findings;
this PR only does F-028, so it does not close the issue. The other
findings need separate work.

CodeRabbit's scan did not establish reachability, so I checked the code
first: on `main`, `isCountAuthorized` filters with
`Array.isArray(filter.kinds) && filter.kinds.some(...)`, so a filter
without `kinds` is never in the set that gets checked, and the unit test
even... (continued)

5437 of 7449 branches covered (72.99%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 1 file covered. (100.0%)

11473 of 13890 relevant lines covered (82.6%)

678.65 hits per line

Jobs
ID Job ID Ran Files Coverage
1 Integration - 44396771360.1 18 Nov 2026 09:03PM UTC 339
34.95
GitHub Action Run
2 Unit - 44396771360.2 18 Nov 2026 09:05PM UTC 339
77.12
GitHub Action Run
Source Files on build 44396771360
  • Tree
  • List 339
  • Changed 2
  • Source Changed 1
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #44396771360
  • 9e64cba8 on github
  • Prev Build on main (#43991451057)
  • Next Build on main (#44398554820)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc