Skip to content

Decoder: reject empty sid field when local AllowEmptySessionID is false #60

Description

@the-sarge

What to build

From the 2026-05-27 multi-agent code review (item M4; tracked as F1 in docs/code-review-followups-2026-05-28.md).

The wire decoder accepts a zero-length sid value from the wire; when the local responder has a non-empty SessionID, the message is rejected only by the later SID-equality check with the generic ErrMessage: session id mismatch. A peer probing whether we accept empty SIDs is therefore indistinguishable in logs from any other SID mismatch. The protocol-level acceptance set is unchanged either way — this is about error-message specificity for operators.

Make the decoder (or its immediate Respond caller) aware of cfg.AllowEmptySessionID, and reject a peer-sent empty sid against a responder requiring a non-empty SessionID with a more specific wrapped error such as ErrMessage: peer sent empty session id.

Smaller alternative if the above proves invasive: document in docs/security-assessment.md that the decoder accepts empty fields and that the protocol-level mismatch is the actual rejection point.

Acceptance criteria

  • Peer-sent empty sid against a responder requiring non-empty SessionID is rejected with a specific wrapped error
  • The error remains errors.Is-matchable as ErrMessage; no new exported error values (public API is frozen)
  • Tests cover the specific rejection and the unchanged behavior when AllowEmptySessionID == true
  • No change to the protocol-level acceptance set (existing vectors and fuzz targets stay green)

Blocked by

None - can start immediately

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/framingWire format / message framingkind/hardeningDefense-in-depth hardening, no API/protocol changepriority/mediumShould land before v1.0.0

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions