diff --git a/.changeset/compose-mount-nostr-config-dir.md b/.changeset/compose-mount-nostr-config-dir.md deleted file mode 100644 index 417898508..000000000 --- a/.changeset/compose-mount-nostr-config-dir.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"nostream": patch ---- - -`nostream start` now mounts the configuration directory it prepared settings in (`NOSTR_CONFIG_DIR`) into the relay container. The compose file mounted `.nostr` in the project whatever `NOSTR_CONFIG_DIR` was, so a relay started with another directory read the default settings from the project instead, without the admission restrictions saved in the directory the CLI had set up. A plain `docker compose up` still mounts `.nostr` in the project. diff --git a/.changeset/docs-setup-pg-version-check.md b/.changeset/docs-setup-pg-version-check.md deleted file mode 100644 index 4473faad8..000000000 --- a/.changeset/docs-setup-pg-version-check.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -docs: check PG_VERSION before upgrading a 2.x relay diff --git a/.changeset/event-message-handler-spec-speed.md b/.changeset/event-message-handler-spec-speed.md deleted file mode 100644 index a845151cc..000000000 --- a/.changeset/event-message-handler-spec-speed.md +++ /dev/null @@ -1,2 +0,0 @@ ---- ---- diff --git a/.changeset/hidden-content-cache-start-always.md b/.changeset/hidden-content-cache-start-always.md deleted file mode 100644 index ea0d9b025..000000000 --- a/.changeset/hidden-content-cache-start-always.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': patch ---- - -fix(nip56): start the hidden-content cache on every worker, not only when reporting is on at boot - -A worker started the cache of hidden report targets only if `nip56.enabled` was true when it booted. On a relay that turned reporting and `hideActionableReports` on later, through a settings reload or a backup restore, the live-delivery check was active but the cache stayed empty, so reported pubkeys and events were still sent to open subscriptions until the next restart. The cache now starts on every worker. Each tick still reads the settings first and queries the database only while `hideActionableReports` is on, so a relay that does not use reporting pays no database cost. diff --git a/.changeset/ignore-cargo-target.md b/.changeset/ignore-cargo-target.md deleted file mode 100644 index ee9eda4bd..000000000 --- a/.changeset/ignore-cargo-target.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"nostream": patch ---- - -Cargo's `target` directory at the workspace root is now in `.gitignore`. It was neither tracked nor ignored, so a release build left about 5 GB in the checkout where `git status` reported it as untracked and any `git add -A` would have staged the build tree, including object files and incremental state. A checkout that builds the Rust workspace the usual way no longer carries it into Git. diff --git a/.changeset/index-tag-filter-matching.md b/.changeset/index-tag-filter-matching.md deleted file mode 100644 index ff8edf011..000000000 --- a/.changeset/index-tag-filter-matching.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -'nostream': patch ---- - -fix(relay): index tag filters instead of comparing every tag with every value - -Matching an event against a `#` filter compared every tag of the event with every value of the filter, and the live broadcast rebuilt each subscription's matcher for every event. One event could therefore cost tags × values comparisons per filter on the worker's event loop, with both sides chosen by clients (security issue #1256). - -A REQ's filters are now compiled once for live delivery and once for its stored events, not per event. An event's single-letter tag values are indexed once and shared by every filter and client of a broadcast. Each tag name then costs set lookups on the smaller side, plus one binary search per `#g` prefix over values sorted once per event. A tag with no value is now skipped; before, it made `#g` prefix filters throw, which cut the broadcast short and stopped a REQ's stored events before `EOSE`. - -A deliberate limit: this adds no per-connection allowance; `maxSubscriptions`, `maxFilters` and `maxFilterValues` still govern admission. `ids`, `authors` and NIP-50 `search` matching are unchanged. diff --git a/.changeset/lnurl-verify-url-private-addresses.md b/.changeset/lnurl-verify-url-private-addresses.md deleted file mode 100644 index 43c6d1450..000000000 --- a/.changeset/lnurl-verify-url-private-addresses.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"nostream": patch ---- - -The LNURL payments processor no longer requests a verify URL that points at a private, loopback or link-local address. The URL comes from the provider's answer to an invoice request, so a malicious provider could use it to make the relay send GET requests to services it can reach. A verify URL on the origin of the configured `invoiceURL` is requested as before, which keeps a provider on a private network working. Any other verify URL has its host resolved by the relay and checked, and no redirect from a verify URL is followed. diff --git a/.changeset/nip05-verify-through-pinned-proxy.md b/.changeset/nip05-verify-through-pinned-proxy.md deleted file mode 100644 index 89a176f45..000000000 --- a/.changeset/nip05-verify-through-pinned-proxy.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': minor ---- - -feat(nip05): verify through an egress proxy by pinning the address that was checked (`nip05.proxy`) - -NIP-05 verification connects directly and ignores `HTTPS_PROXY`, because a proxy resolves the host name itself and so skips the check that refuses private addresses. A relay that reaches the internet only through an egress proxy could therefore not verify NIP-05 identifiers at all. The new setting `nip05.proxy` (`disabled`, the default, or `pin`) gives that relay a way back. With `pin`, the relay sends the requests through the proxy in `HTTPS_PROXY`, but resolves the host itself, refuses a private, loopback or link-local address before the proxy is contacted, and asks the proxy for `CONNECT
:443` with the address it checked. TLS runs through the tunnel with the host name as `servername`, so the certificate is still checked against the host. A redirect target goes through the same steps. A proxy that refuses the `CONNECT` makes the verification fail with a reason naming the proxy and the host. With the setting absent or `disabled`, nothing changes. diff --git a/.changeset/readyz-own-connection.md b/.changeset/readyz-own-connection.md deleted file mode 100644 index 37026c239..000000000 --- a/.changeset/readyz-own-connection.md +++ /dev/null @@ -1,15 +0,0 @@ ---- ---- - -fix(readyz): probe Postgres on a connection the readiness check owns - -`pingDatabase()` took a connection from the master pool, whose `max` is 3. Three -queries that never completed held every slot, so the readiness ping waited for an -acquire (up to 60s) behind a 3s race that neither cancelled nor released anything: -`/readyz` answered `database: {ok:false}` against a database that answered a fresh -client in milliseconds, until the process was restarted. - -The ping now opens its own client from the master connection config, bounded by -`ADMIN_DEPENDENCY_PING_TIMEOUT_MS` for connect, query and statement, and destroys -that connection when the timeout fires instead of leaving it open. `/readyz` itself -is unchanged: same endpoint, same JSON, same 200/503. diff --git a/.changeset/settings-notification-redact-nested-urls.md b/.changeset/settings-notification-redact-nested-urls.md deleted file mode 100644 index 2df8fb691..000000000 --- a/.changeset/settings-notification-redact-nested-urls.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': patch ---- - -fix(admin): hide a webhook url in the settings-change notification when a parent path is replaced - -The notification sent to the operator's recipients after a settings change redacts secrets by the settings path of each value. A change to a path above a webhook target, such as replacing `admin.notifications` or `admin`, carried the whole object as its value, and the redaction ran on it without that path, so the `url` of each notification target (a Discord or Slack webhook with a token in it) went out in the notification. The value of each change is now redacted with the path it was written at, so the url is replaced by `***` in the notification and in the response of the settings request. diff --git a/.changeset/update-keep-ssl-out-of-stash.md b/.changeset/update-keep-ssl-out-of-stash.md deleted file mode 100644 index f8ebd2405..000000000 --- a/.changeset/update-keep-ssl-out-of-stash.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"nostream": patch ---- - -`nostream update` no longer stashes the files under `nginx/ssl`. They were neither tracked nor ignored, so the stash took the certificates the nginx compose file mounts, private keys included, into a Git object any local account can read, and restoring them did not keep the owner-only mode they had. The directory is now in `.gitignore`, and the stash command leaves it out as well, because it runs before the pull that brings that rule to an older checkout. diff --git a/.changeset/v3-v4-schedule.md b/.changeset/v3-v4-schedule.md deleted file mode 100644 index 950d4b64a..000000000 --- a/.changeset/v3-v4-schedule.md +++ /dev/null @@ -1,4 +0,0 @@ ---- ---- - -docs: the v3/v4 development schedule in the README diff --git a/.changeset/wot-bound-graph-rebuilds.md b/.changeset/wot-bound-graph-rebuilds.md deleted file mode 100644 index f1498081c..000000000 --- a/.changeset/wot-bound-graph-rebuilds.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': patch ---- - -fix(wot): bound a trust graph rebuild and space out the rebuilds contact lists trigger - -A Web of Trust rebuild read follow lists one at a time with no limit on accounts, lists or follows, and every contact list (kind 3) from an account in the graph started or queued another full rebuild. A rebuild now stops at `wot.maxPubkeys`, `wot.maxFollowListReads` or `wot.maxEdges` (defaults 500000, 10000 and 2000000), logs which limit it hit, and keeps the graph built so far, which can only trust fewer accounts, never more. Follow lists are read 100 at a time, and a `p` value that is not a 64-character hex key is no longer looked up as an author prefix. Rebuilds triggered by contact lists wait `wot.minRebuildIntervalSeconds` (default 60) after the previous one ended. A deliberate limit: a follow-list change can take up to that interval longer to reach the graph. diff --git a/.changeset/wot-graph-votes-and-settings-key.md b/.changeset/wot-graph-votes-and-settings-key.md deleted file mode 100644 index efc2627e0..000000000 --- a/.changeset/wot-graph-votes-and-settings-key.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': patch ---- - -fix(wot): count one vote per follower and stop serving a trust graph built for other settings - -Two gaps in the Web of Trust graph could grant a proof-of-work discount to an account that should not have it. A contact list (kind 3) that repeated the same `p` tag counted once per repetition towards `wot.minimumFollowers` when its follow list was read from the database, so one account could satisfy a threshold meant for several. Each follower now counts once. The built graph also stayed in use after `wot.seedPubkey`, `wot.maxDepth` or `wot.minimumFollowers` changed through a settings reload, so the old distances kept granting discounts until another event happened to trigger a rebuild. The graph now remembers the settings it was built for, is rebuilt when they change, and grants nothing while a rebuild for the new settings has not completed or has failed. diff --git a/.changeset/wot-invalidate-graph-across-workers.md b/.changeset/wot-invalidate-graph-across-workers.md deleted file mode 100644 index fb18ec829..000000000 --- a/.changeset/wot-invalidate-graph-across-workers.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': patch ---- - -fix(wot): rebuild the trust graph of every worker when a contact list changes it - -Each worker keeps its own Web of Trust graph, and only the worker that handled a contact list rebuilt it. The other workers kept granting a proof-of-work discount for a relationship the author had just removed, until their next rebuild, which could be a whole `wot.refreshIntervalHours` away. A worker that applies a contact list now publishes a token in the cache, and every worker compares it with the one its graph was built under and rebuilds when it differs, and asks again if that rebuild fails, spaced out by `wot.minRebuildIntervalSeconds` like a rebuild for a contact list it handled itself. A lookup reads the token at most once a second. If the cache cannot be read or written, the worker keeps answering from its own graph. diff --git a/.changeset/wot-lowercase-follow-pubkeys.md b/.changeset/wot-lowercase-follow-pubkeys.md deleted file mode 100644 index 79e0e0994..000000000 --- a/.changeset/wot-lowercase-follow-pubkeys.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'nostream': patch ---- - -fix(wot): use one lowercase form for every pubkey in the trust graph and its cache - -The value of a `p` tag in a contact list is any string, while an event's author is always lowercase hex. The Web of Trust graph kept a followed pubkey as it was written, so an uppercase spelling could sit in the graph and in the `wot:follows:` cache next to the lowercase form of the same account, and an account the graph had reached only through an uppercase tag did not trigger a rebuild when its own contact list changed. The graph and its cache keys now lowercase every pubkey they take in, including entries an earlier version left in the cache, and a `p` tag without a value is ignored. A `wot.seedPubkey` written in uppercase, which its pattern allows, is read as the same lowercase pubkey, so the seed is the account whose events are lowercase. diff --git a/CHANGELOG.md b/CHANGELOG.md index 38916809f..dd73dcbee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,55 @@ # nostream +## 3.18.0 + +### Minor Changes + +- [#1341](https://github.com/cameri/nostream/pull/1341) [`21ddb8e`](https://github.com/cameri/nostream/commit/21ddb8e59eca732250b42d701396bd687e4b4d4f) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - feat(nip05): verify through an egress proxy by pinning the address that was checked (`nip05.proxy`) + + NIP-05 verification connects directly and ignores `HTTPS_PROXY`, because a proxy resolves the host name itself and so skips the check that refuses private addresses. A relay that reaches the internet only through an egress proxy could therefore not verify NIP-05 identifiers at all. The new setting `nip05.proxy` (`disabled`, the default, or `pin`) gives that relay a way back. With `pin`, the relay sends the requests through the proxy in `HTTPS_PROXY`, but resolves the host itself, refuses a private, loopback or link-local address before the proxy is contacted, and asks the proxy for `CONNECT
:443` with the address it checked. TLS runs through the tunnel with the host name as `servername`, so the certificate is still checked against the host. A redirect target goes through the same steps. A proxy that refuses the `CONNECT` makes the verification fail with a reason naming the proxy and the host. With the setting absent or `disabled`, nothing changes. + +### Patch Changes + +- [#1380](https://github.com/cameri/nostream/pull/1380) [`daf3285`](https://github.com/cameri/nostream/commit/daf3285584c3f51a6c57e3e14b2124b453a9a577) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - `nostream start` now mounts the configuration directory it prepared settings in (`NOSTR_CONFIG_DIR`) into the relay container. The compose file mounted `.nostr` in the project whatever `NOSTR_CONFIG_DIR` was, so a relay started with another directory read the default settings from the project instead, without the admission restrictions saved in the directory the CLI had set up. A plain `docker compose up` still mounts `.nostr` in the project. + +- [#1241](https://github.com/cameri/nostream/pull/1241) [`3ac2880`](https://github.com/cameri/nostream/commit/3ac28808e46f3ec32b4991c4cda1924327c5675f) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - fix(nip56): start the hidden-content cache on every worker, not only when reporting is on at boot + + A worker started the cache of hidden report targets only if `nip56.enabled` was true when it booted. On a relay that turned reporting and `hideActionableReports` on later, through a settings reload or a backup restore, the live-delivery check was active but the cache stayed empty, so reported pubkeys and events were still sent to open subscriptions until the next restart. The cache now starts on every worker. Each tick still reads the settings first and queries the database only while `hideActionableReports` is on, so a relay that does not use reporting pays no database cost. + +- [#1393](https://github.com/cameri/nostream/pull/1393) [`c0acdd6`](https://github.com/cameri/nostream/commit/c0acdd69477e85915ebbd1f2069a6d27d051ad88) Thanks [@chappie-daemon](https://github.com/chappie-daemon)! - Cargo's `target` directory at the workspace root is now in `.gitignore`. It was neither tracked nor ignored, so a release build left about 5 GB in the checkout where `git status` reported it as untracked and any `git add -A` would have staged the build tree, including object files and incremental state. A checkout that builds the Rust workspace the usual way no longer carries it into Git. + +- [#1287](https://github.com/cameri/nostream/pull/1287) [`4925f70`](https://github.com/cameri/nostream/commit/4925f702ec68dc559dadab75bda0f2b4991afe0c) Thanks [@chappie-daemon](https://github.com/chappie-daemon)! - fix(relay): index tag filters instead of comparing every tag with every value + + Matching an event against a `#` filter compared every tag of the event with every value of the filter, and the live broadcast rebuilt each subscription's matcher for every event. One event could therefore cost tags × values comparisons per filter on the worker's event loop, with both sides chosen by clients (security issue [#1256](https://github.com/cameri/nostream/issues/1256)). + + A REQ's filters are now compiled once for live delivery and once for its stored events, not per event. An event's single-letter tag values are indexed once and shared by every filter and client of a broadcast. Each tag name then costs set lookups on the smaller side, plus one binary search per `#g` prefix over values sorted once per event. A tag with no value is now skipped; before, it made `#g` prefix filters throw, which cut the broadcast short and stopped a REQ's stored events before `EOSE`. + + A deliberate limit: this adds no per-connection allowance; `maxSubscriptions`, `maxFilters` and `maxFilterValues` still govern admission. `ids`, `authors` and NIP-50 `search` matching are unchanged. + +- [#1392](https://github.com/cameri/nostream/pull/1392) [`9921537`](https://github.com/cameri/nostream/commit/992153739951e5465759a9f46d73495216fd02b2) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - The LNURL payments processor no longer requests a verify URL that points at a private, loopback or link-local address. The URL comes from the provider's answer to an invoice request, so a malicious provider could use it to make the relay send GET requests to services it can reach. A verify URL on the origin of the configured `invoiceURL` is requested as before, which keeps a provider on a private network working. Any other verify URL has its host resolved by the relay and checked, and no redirect from a verify URL is followed. + +- [#1295](https://github.com/cameri/nostream/pull/1295) [`df1f672`](https://github.com/cameri/nostream/commit/df1f6723a93a14386d4059f75bddda1f14f88f47) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - fix(admin): hide a webhook url in the settings-change notification when a parent path is replaced + + The notification sent to the operator's recipients after a settings change redacts secrets by the settings path of each value. A change to a path above a webhook target, such as replacing `admin.notifications` or `admin`, carried the whole object as its value, and the redaction ran on it without that path, so the `url` of each notification target (a Discord or Slack webhook with a token in it) went out in the notification. The value of each change is now redacted with the path it was written at, so the url is replaced by `***` in the notification and in the response of the settings request. + +- [#1361](https://github.com/cameri/nostream/pull/1361) [`6a2e8a8`](https://github.com/cameri/nostream/commit/6a2e8a809bee3edb3c8f31bf15b546f650d56945) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - `nostream update` no longer stashes the files under `nginx/ssl`. They were neither tracked nor ignored, so the stash took the certificates the nginx compose file mounts, private keys included, into a Git object any local account can read, and restoring them did not keep the owner-only mode they had. The directory is now in `.gitignore`, and the stash command leaves it out as well, because it runs before the pull that brings that rule to an older checkout. + +- [#1339](https://github.com/cameri/nostream/pull/1339) [`f0a3325`](https://github.com/cameri/nostream/commit/f0a3325eca03cdf2463933de06a08fb741743e2b) Thanks [@chappie-daemon](https://github.com/chappie-daemon)! - fix(wot): bound a trust graph rebuild and space out the rebuilds contact lists trigger + + A Web of Trust rebuild read follow lists one at a time with no limit on accounts, lists or follows, and every contact list (kind 3) from an account in the graph started or queued another full rebuild. A rebuild now stops at `wot.maxPubkeys`, `wot.maxFollowListReads` or `wot.maxEdges` (defaults 500000, 10000 and 2000000), logs which limit it hit, and keeps the graph built so far, which can only trust fewer accounts, never more. Follow lists are read 100 at a time, and a `p` value that is not a 64-character hex key is no longer looked up as an author prefix. Rebuilds triggered by contact lists wait `wot.minRebuildIntervalSeconds` (default 60) after the previous one ended. A deliberate limit: a follow-list change can take up to that interval longer to reach the graph. + +- [#1294](https://github.com/cameri/nostream/pull/1294) [`76fa452`](https://github.com/cameri/nostream/commit/76fa4520054bd51202cefd4967501dbc361c8bc6) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - fix(wot): count one vote per follower and stop serving a trust graph built for other settings + + Two gaps in the Web of Trust graph could grant a proof-of-work discount to an account that should not have it. A contact list (kind 3) that repeated the same `p` tag counted once per repetition towards `wot.minimumFollowers` when its follow list was read from the database, so one account could satisfy a threshold meant for several. Each follower now counts once. The built graph also stayed in use after `wot.seedPubkey`, `wot.maxDepth` or `wot.minimumFollowers` changed through a settings reload, so the old distances kept granting discounts until another event happened to trigger a rebuild. The graph now remembers the settings it was built for, is rebuilt when they change, and grants nothing while a rebuild for the new settings has not completed or has failed. + +- [#1348](https://github.com/cameri/nostream/pull/1348) [`bc40555`](https://github.com/cameri/nostream/commit/bc405551cf113d724ae2be1611e47cfd831573cb) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - fix(wot): rebuild the trust graph of every worker when a contact list changes it + + Each worker keeps its own Web of Trust graph, and only the worker that handled a contact list rebuilt it. The other workers kept granting a proof-of-work discount for a relationship the author had just removed, until their next rebuild, which could be a whole `wot.refreshIntervalHours` away. A worker that applies a contact list now publishes a token in the cache, and every worker compares it with the one its graph was built under and rebuilds when it differs, and asks again if that rebuild fails, spaced out by `wot.minRebuildIntervalSeconds` like a rebuild for a contact list it handled itself. A lookup reads the token at most once a second. If the cache cannot be read or written, the worker keeps answering from its own graph. + +- [#1342](https://github.com/cameri/nostream/pull/1342) [`da83636`](https://github.com/cameri/nostream/commit/da83636c9a0d76a05dfdcf7fd3a722ab76714828) Thanks [@Priyanshubhartistm](https://github.com/Priyanshubhartistm)! - fix(wot): use one lowercase form for every pubkey in the trust graph and its cache + + The value of a `p` tag in a contact list is any string, while an event's author is always lowercase hex. The Web of Trust graph kept a followed pubkey as it was written, so an uppercase spelling could sit in the graph and in the `wot:follows:` cache next to the lowercase form of the same account, and an account the graph had reached only through an uppercase tag did not trigger a rebuild when its own contact list changed. The graph and its cache keys now lowercase every pubkey they take in, including entries an earlier version left in the cache, and a `p` tag without a value is ignored. A `wot.seedPubkey` written in uppercase, which its pattern allows, is read as the same lowercase pubkey, so the seed is the account whose events are lowercase. + ## 3.17.1 ### Patch Changes diff --git a/package.json b/package.json index 6671d952e..03232066a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nostream", - "version": "3.17.1", + "version": "3.18.0", "packageManager": "pnpm@10.33.0", "private": true, "description": "A Nostr relay written in Typescript.",