You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(admin): refuse pubkeys in settings lists that cannot match - #1240
The pubkey blacklist, the pubkey whitelist and the rate-limit bypass list (limits.event.pubkey.blacklist, limits.event.pubkey.whitelist, limits.event.whitelists.pubkeys) are compared with the pubkey of each event as they are written (blacklist.includes(event.pubkey) in EventMessageHandler). An event's pubkey is always 64 lowercase hex characters, because the event schema requires it.
The settings API saved any value in these lists. A blacklist entry in uppercase hex was stored, never matched an event, and so the pubkey it was meant to ban could still publish. The moderation endpoints already normalize what they save (normalizePubkeyList), but the generic PATCH /admin/settings does not.
validateSettings now rejects an entry that is not a 64-character lowercase hex pubkey and names the entry (for example limits.event.pubkey.blacklist[1]). It runs for every path that saves settings: the settings API, the CLI config set, backup restore, the moderation and notification controllers, and the validate endpoint, so there is one check instead of one per path. A value that is not a list is already reported by the existing shape check.
A deliberate limit: I reject an entry instead of converting it, because converting would change what an operator wrote without telling them. validateSettings is not run at startup, so a settings file that already holds such an entry still starts. The next settings change made through the paths above is refused until the entry is fixed, and the message says which one. That entry was not enforcing anything, so I preferred making it visible.
Related Issue
Partly addresses #1022 (F-011). The other findings in that issue are handled separately.
Motivation and Context
A blacklist that silently does not ban is worse than an error. CodeRabbit's scan did not establish reachability, so I checked the code: the comparison is exact, the event pubkey is always lowercase, and the generic PATCH saved the list unchanged.
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Non-functional change (docs, style, minor refactor)
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
My code follows the code style of this project.
My change requires a change to the documentation.
I have updated the documentation accordingly.
I have read the CONTRIBUTING document.
I have added tests to cover my code changes.
I added a changeset, or this is docs-only and I added an empty changeset.
All new and existing tests passed.
Summary by CodeRabbit
Bug Fixes
Settings validation now checks event pubkey blacklist, whitelist, and event-whitelist entries. Keys must be exactly 64 lowercase hexadecimal characters; invalid entries are rejected with a validation issue.
The validation applies when updating settings through the API and when using related settings workflows, including the CLI, backup restore, and validation endpoint.
No actionable comments were generated in the recent review.
Walkthrough
The change adds validation for three settings pubkey lists. Entries must be 64-character lowercase hexadecimal strings. Utility and admin API tests cover accepted and rejected entries, including whether the API saves them.
validateSettings checks the event pubkey blacklist, event pubkey whitelist, and event whitelists’ pubkeys. Tests cover valid lowercase keys, empty or absent lists, and invalid entries.
Verify admin API handling test/unit/routes/admin-settings.spec.ts, .changeset/settings-pubkey-lists-lowercase-hex.md
Admin API tests verify that uppercase entries are rejected without being saved and lowercase entries are accepted and saved. The Changesets note describes the validation and its stated effects.
cameri/nostream#1022: This change rejects uppercase and otherwise invalid blacklist entries through settings validation. It does not canonicalize entries as the issue suggests.
Merge Risk: Minimal · up to bbf01
This change rejects settings pubkey-list entries that could never match an event pubkey. Existing settings files still start, and the next update through the listed paths is refused until the invalid entry is fixed. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: settings lists now refuse pubkeys that cannot match. The changeset validates blacklist, whitelist, and event-whitelist pubkey entries as 64-character lowercase hex. Th…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check
Explanation
The title names the main change: settings lists now refuse pubkeys that cannot match. The changeset validates blacklist, whitelist, and event-whitelist pubkey entries as 64-character lowercase hex. The title uses the fix(admin) scope, which matches the admin settings API and CLI paths in the changeset.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks each key in line, Sixty-four small marks must shine. Lowercase hex can pass the gate, Uppercase keys must hesitate. The saved list now follows suit, And hops away with keys checked out.
Recent review info
Automatic approval policy
Commit: bbf014e4b356.
Setting
Effective value
Source
Automatic approvals
Enabled
Global configuration
Merge risk
Minimal
Global configuration
Security risk
Not set
Global configuration
Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: afdad15f-b853-44c4-9cd6-9f0ad9ee650e
Commits
Reviewing files that changed from the base of the PR and between 549a97d and bbf014e.
Files selected for processing: 4
.changeset/settings-pubkey-lists-lowercase-hex.md
src/utils/settings-config.ts
test/unit/routes/admin-settings.spec.ts
test/unit/utils/settings-config.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
Adds shared checks for the event pubkey blacklist, whitelist, and rate-limit bypass list.
Settings reject pubkeys that event lists cannot match.
Priyanshubhartistm explicitly acknowledges that existing invalid entries block later settings changes until corrected, while startup remains unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The pubkey blacklist, the pubkey whitelist and the rate-limit bypass list (
limits.event.pubkey.blacklist,limits.event.pubkey.whitelist,limits.event.whitelists.pubkeys) are compared with the pubkey of each event as they are written (blacklist.includes(event.pubkey)inEventMessageHandler). An event's pubkey is always 64 lowercase hex characters, because the event schema requires it.The settings API saved any value in these lists. A blacklist entry in uppercase hex was stored, never matched an event, and so the pubkey it was meant to ban could still publish. The moderation endpoints already normalize what they save (
normalizePubkeyList), but the genericPATCH /admin/settingsdoes not.validateSettingsnow rejects an entry that is not a 64-character lowercase hex pubkey and names the entry (for examplelimits.event.pubkey.blacklist[1]). It runs for every path that saves settings: the settings API, the CLIconfig set, backup restore, the moderation and notification controllers, and the validate endpoint, so there is one check instead of one per path. A value that is not a list is already reported by the existing shape check.A deliberate limit: I reject an entry instead of converting it, because converting would change what an operator wrote without telling them.
validateSettingsis not run at startup, so a settings file that already holds such an entry still starts. The next settings change made through the paths above is refused until the entry is fixed, and the message says which one. That entry was not enforcing anything, so I preferred making it visible.Related Issue
Partly addresses #1022 (F-011). The other findings in that issue are handled separately.
Motivation and Context
A blacklist that silently does not ban is worse than an error. CodeRabbit's scan did not establish reachability, so I checked the code: the comparison is exact, the event pubkey is always lowercase, and the generic PATCH saved the list unchanged.
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist:
Summary by CodeRabbit