Conversation
🔐 Codex Security Review
|
…xt cap Two memory-store defects seats hit in the wild, both reproduced and fixed: 1. mem patch silently succeeds on no-op patches. A patch whose result is byte-identical to the current value (context-only hunks, delete-then- reinsert pairs, or the empty diff diff -u emits on identical files) applied cleanly, published a fresh head event with identical content, echoed the input diff, printed 'wrote ...' with a sha256 equal to the base-hash (by construction), and exited 0 — while the stored value never changed and the event chain still advanced. Neither the 'wrote' line nor a new event id is mutation evidence; the only evidence is post-write hash inequality. cmd_patch now refuses byte-identical results before the dry-run branch: nonzero exit, no event published. 2. Writes sized against NIP44_PLAINTEXT_MAX (65,535) bounce deep inside nip44::encrypt with a generic 'message too long'. The NIP-44 v2 pad caps the *serialized body* at 65,536 - 128 = 65,408 bytes, and the serialized body is the raw value plus the JSON envelope (slug + ~22-28 bytes) plus one byte per escaped newline/tab/quote/backslash. A raw 65,080-byte value with 400 newlines (65,518 serialized) passed the 65,535 raw-value check and the 65,535 serialized-body check, then failed at the crypto layer with no actionable detail. build_event now enforces the real 65,408 serialized cap up front with an error naming the serialized length, raw length, and the exact trim amount. Also worth noting for release notes: the currently-deployed CLI vintage maps a relay 'duplicate:' (NIP-33 LWW-dominated write) response to success — concurrent patches against the same base both report 'wrote' while only one lands. Current source already converts this to a Conflict; that fix rides the same release as this one. Tests: four no-op refusal shapes pinned (context-only, delete-reinsert, empty-diff, real-change control), ciphertext-cap boundary tests (at-cap accepted, one-over rejected with exact trim advice, escape-overhead arithmetic matching the 65,080 + 400-newline repro). buzz-core 257, buzz-cli 477, all green; clippy and fmt clean. Signed-off-by: Aydin Goze Polat <mrchesstr@gmail.com>
gozepolat
force-pushed
the
mem-encode-fixes
branch
from
September 15, 2026 08:11
8776305 to
cea7045
Compare
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.
Summary
Two
buzz memdefects that seats hit in the wild, both reproduced against a live relay and fixed client-side:mem patchsilently succeeds on no-op patches. A patch whose result is byte-identical to the current value (context-only hunks, delete-then-reinsert pairs, or the empty diffdiff -uemits for identical files) applied cleanly, published a fresh head event carrying identical content, echoed the input diff, printedwrote …with a sha256 equal to the base-hash (by construction), and exited 0 — while the stored value never changed and the event chain still advanced. Neither thewroteline nor a new event id is mutation evidence; the only mutation evidence is post-write hash inequality, which a no-op can never produce.cmd_patchnow refuses byte-identical results before the dry-run branch: nonzero exit, no event published.Writes sized against
NIP44_PLAINTEXT_MAX(65,535) bounce deep insidenip44::encryptwith a genericmessage too long. The NIP-44 v2 pad caps the serialized body at65_536 - 128 = 65,408bytes, and the serialized body is the raw value plus the JSON envelope (slug + ~22–28 bytes) plus one byte per escaped newline/tab/quote/backslash. A raw 65,080-byte value with 400 newlines (65,518 serialized) passed the 65,535 raw-value check and the 65,535 serialized-body check, then failed at the crypto layer with no actionable detail.build_eventnow enforces the real 65,408 serialized cap up front with an error naming the serialized length, the raw length, and the exact trim amount.Also for release notes: the currently-deployed CLI vintage maps a relay
duplicate:(NIP-33 LWW-dominated write) response to success — concurrent patches against the same base both reportwrotewhile only one lands. Current source already converts this to aConflict; that fix rides the same release as this one.End-to-end verification (source-built CLI vs. live relay)
serialized body exceeds 65408-byte NIP-44 v2 limit (65409 bytes; raw value 65372 bytes + JSON envelope and escape overhead). Trim the raw value by at least 2 bytes and retry.Tests
Four no-op refusal shapes pinned (context-only, delete-reinsert, empty-diff, real-change control); ciphertext-cap boundary tests (at-cap accepted, one-over rejected with exact trim advice, escape-overhead arithmetic matching the 65,080 + 400-newline repro).
buzz-core257 passed,buzz-cli477 passed;cargo clippy --all-targetsandcargo fmtclean;cargo check --workspaceclean.Effective-budget guidance (docs in the const)
For markdown-dense values, budget against the serialized body: raw value ≤ 65,408 − envelope(~28) − newlines/tabs/quotes count. Plain values cap at ~65,370–65,380 depending on slug length.