Skip to content

keep-core: zeroize NIP-49 ncryptsec assembly buffer on drop#831

Merged
kwsantiago merged 1 commit into
mainfrom
fix/nip49-zeroize-concat-buffer
Jul 16, 2026
Merged

keep-core: zeroize NIP-49 ncryptsec assembly buffer on drop#831
kwsantiago merged 1 commit into
mainfrom
fix/nip49-zeroize-concat-buffer

Conversation

@kwsantiago

Copy link
Copy Markdown
Contributor

Ncryptsec::encrypt assembles the version/log_n/salt/nonce/security-byte/ciphertext into a plain Vec<u8> for bech32 encoding, then drops it without clearing. It never holds the plaintext key (that stays in the Zeroizing symmetric key and the secret_key slice), but the salt and nonce are worth clearing from memory rather than leaving them for a later heap read.

Change

  • Wrap the assembly buffer in Zeroizing so it is cleared on drop. Vec::with_capacity(91) is the exact ncryptsec byte length, so no reallocation leaves an un-zeroed intermediate copy behind.

No behavior change: the bech32 output is byte-identical.

Verification

  • cargo test -p keep-core --lib keys: passed (ncryptsec encrypt/decrypt round-trips). cargo clippy -p keep-core --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: 42 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: 10d4fb0e-bab5-4e52-87d6-1b3a4d88f9a1

📥 Commits

Reviewing files that changed from the base of the PR and between 89ee825 and fdba31a.

📒 Files selected for processing (1)
  • keep-core/src/keys.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nip49-zeroize-concat-buffer

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 662137f into main Jul 16, 2026
9 checks passed
@kwsantiago kwsantiago deleted the fix/nip49-zeroize-concat-buffer branch July 16, 2026 16:58
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