Skip to content

keep-nip46: fail closed instead of panicking on unrouted encryption method#827

Merged
kwsantiago merged 1 commit into
mainfrom
fix/nip46-unreachable-method-arm
Jul 16, 2026
Merged

keep-nip46: fail closed instead of panicking on unrouted encryption method#827
kwsantiago merged 1 commit into
mainfrom
fix/nip46-unreachable-method-arm

Conversation

@kwsantiago

Copy link
Copy Markdown
Contributor

Hardening found by an audit of panic sites on untrusted-input decode paths.

The encryption dispatch in the NIP-46 server re-matches the client-supplied method string inside the arm that the outer dispatch routes nip44_encrypt / nip44_decrypt / nip04_encrypt / nip04_decrypt into, with _ => unreachable!(). The invariant holds today, but it couples two match arms in different places on an attacker-controlled string: if the outer list ever gains a method the inner match does not handle, an unsupported method string panics the signer process (denial of service) instead of returning an error.

Changes

  • Replace the unreachable!() arm with a logged, fail-closed Unsupported method error response.

Audit context

A sweep of unwrap() / expect() / panic! / unreachable! in non-test code across the wire and IPC decode surfaces (keep-frost-net protocol/event/node, keep-nip46 request handling, keep-mobile FFI) found no attacker-reachable panic besides this fragile spot. The remaining sites are locally-verified invariants (expect("just inserted") immediately after a map insert), startup-time initialization, or environmental conditions, none reachable from untrusted input.

Verification

  • cargo test -p keep-nip46: 189 passed.
  • cargo clippy -p keep-nip46 --all-targets: clean.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kwsantiago, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 525e9624-4f1d-4fcd-93fb-d1dc31cc7fee

📥 Commits

Reviewing files that changed from the base of the PR and between f468f81 and 4c143f0.

📒 Files selected for processing (1)
  • keep-nip46/src/server.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nip46-unreachable-method-arm

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kwsantiago
kwsantiago merged commit 279c9d5 into main Jul 16, 2026
9 checks passed
@kwsantiago
kwsantiago deleted the fix/nip46-unreachable-method-arm branch July 16, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant