What to build
From the 2026-05-27 multi-agent code review (item M6; tracked as F2 in docs/code-review-followups-2026-05-28.md).
newMessageReader performs only a 3-byte header check before field-by-field parsing. Per-field size caps exist (64 KiB AD, 1 KiB sid, etc.) but there is no upfront aggregate length check, so a server calling Respond under a flood of maximally-sized (~66 KiB) malformed messages allocates field-by-field on every call before any cryptographic filter.
Add a maxMessageLen constant derived from the per-field caps plus header overhead (or a documented round constant such as 128 KiB, comfortably above any valid message) and reject longer inputs at the top of newMessageReader with ErrMessage. No valid message length is reduced; this only rejects invalid oversized input earlier.
Acceptance criteria
Blocked by
None - can start immediately
What to build
From the 2026-05-27 multi-agent code review (item M6; tracked as F2 in
docs/code-review-followups-2026-05-28.md).newMessageReaderperforms only a 3-byte header check before field-by-field parsing. Per-field size caps exist (64 KiB AD, 1 KiB sid, etc.) but there is no upfront aggregate length check, so a server callingRespondunder a flood of maximally-sized (~66 KiB) malformed messages allocates field-by-field on every call before any cryptographic filter.Add a
maxMessageLenconstant derived from the per-field caps plus header overhead (or a documented round constant such as 128 KiB, comfortably above any valid message) and reject longer inputs at the top ofnewMessageReaderwithErrMessage. No valid message length is reduced; this only rejects invalid oversized input earlier.Acceptance criteria
maxMessageLenconstant defined and documented (derivation or rationale in a comment)ErrMessageBlocked by
None - can start immediately