Conversation
nostr's nip44::encrypt refuses plaintext larger than 65,408 bytes (MAX_SUPPORTED_PLAINTEXT_SIZE = 65,536 - 128), 127 below the NIP-44 spec cap of 65,535. Our size gates checked the spec cap, so bodies in the 65,409..=65,535 blind spot passed the gate and then failed cryptically inside encrypt with "message too long" instead of a clean size error. Separate the spec value from the implementation limit: keep the spec constants (NIP44_PLAINTEXT_MAX, OBSERVER_MAX_PLAINTEXT_LEN, MAX_PLAINTEXT_BYTES = 65,535) as documented values and add NIP44_ENCRYPT_MAX = 65,408 for the real gate. Move the encrypt/decrypt gates in engram, observer, and private_managed_agent to the effective limit, and make the size-limit errors carry both the limit and the actual byte count (pairing/session decrypt is left unchanged). Add regression tests in engram: one that rejects a body sized inside the blind spot via our gate, and one that watches nostr's external limit with literal 65,408/65,409 bounds so a future nostr change is caught. Fix two stale comments whose intent broke once the gate moved (the mem set stdin guard and the existing body_too_large test). Signed-off-by: gruming <tnalsl1984@naver.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
🔐 Codex Security Review
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
nostr's
nip44::encryptrefuses plaintext larger than 65,408 bytes (MAX_SUPPORTED_PLAINTEXT_SIZE = 65_536 - 128, nostr 0.44.7nip44/v2.rs:35; unchanged in 0.45.1), 127 bytes below the NIP-44 spec cap of 65,535. Our size gates (engrambuild_event, observer, private managed agent) checked the spec cap, so bodies serialized to 65,409..=65,535 bytes passed the gate and then failed inside encrypt with a baremessage too longinstead of a size error that reports the byte count.What
NIP44_ENCRYPT_MAX = 65_408(implementation cap) next to the unchanged spec constants; the 5 encrypt/decrypt gates now use it and the errors report the limit and actual size.build_event_rejects_inside_nip44_blind_spot— 65,500-byte serialized body →BodyTooLarge(wasEncrypt("message too long")); (b)nip44_plaintext_boundary_is_65408— literal 65,408 ok / 65,409 err, guards against silent upstream changes; (c) existing oversize test pinned to literal 65,535 with a serialized-size assertion.buzz-climem setcomment corrected (no logic change).cargo test -p buzz-core257 passed ·-p buzz-cli463 passed ·-p buzz-acp914 passed ·cargo fmt --checkclean.Draft: opened for review; not requesting merge yet.