Skip to content

fix: validate CONNACK session state - #143

Open
OllieinCanada wants to merge 1 commit into
microsoft:mainfrom
OllieinCanada:fix/connack-session-state-137
Open

fix: validate CONNACK session state#143
OllieinCanada wants to merge 1 commit into
microsoft:mainfrom
OllieinCanada:fix/connack-session-state-137

Conversation

@OllieinCanada

Copy link
Copy Markdown

Fixes #137

Problem

The client accepted Session Present = 1 even after a Clean Start request or when it had no corresponding local session state. That can leave client and broker with contradictory views of packet identifiers, subscriptions, and in-flight messages.

Fix

Track whether the client has resumable local session state and validate successful CONNACK packets against both that state and the preceding Clean Start value. Contradictory responses now fail as protocol errors, while a legitimate reconnect with retained local state remains accepted. Existing session-expiration paths clear the new state marker.

Tests

Deterministic in-memory transport tests cover:

  • Clean Start with Session Present = 1 is rejected
  • a fresh client with Session Present = 1 is rejected
  • a persistent reconnect with matching local state is accepted
  • the existing successful connection path remains unchanged

Validation completed with isolated build artifacts:

  • focused simple suite: 5 passed
  • full unit suite: 262 passed
  • standard and websocket integration matrices: passed
  • both repository clippy feature matrices with warnings denied: passed
  • cargo fmt --all -- --check: passed
  • git diff --check: passed

Signed-off-by: Oliver Slapinski <olliefromcanada@gmail.com>
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.

Client accepts inconsistent CONNACK Session Present state

1 participant