Reject AUTH, server-sent DISCONNECT and payload bytes in UNSUBACK below v5. Publish Will on write failure. - #583
Reject AUTH, server-sent DISCONNECT and payload bytes in UNSUBACK below v5. Publish Will on write failure.#583kareem-wolfssl wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Pull request overview
This PR tightens MQTT protocol-level compliance by rejecting v5-only packets (AUTH, server-sent DISCONNECT) on v3.1.1 sessions, enforcing exact UNSUBACK length rules for v3.1.1, and ensuring broker-side Will publishing occurs on direct-response write failures.
Changes:
- Enforce v3.1.1 UNSUBACK Remaining Length == 2, while allowing v5 UNSUBACK bodies.
- Reject AUTH (type 15) and server-sent DISCONNECT on protocol level 4 sessions (read + write paths).
- Normalize broker direct-response write failures as fatal so connections close and Wills publish; add tests for these scenarios.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_mqtt_packet.c | Adds UNSUBACK decoding tests for v3.1.1 exact-length and v5 longer-body acceptance. |
| tests/test_mqtt_client.c | Adds client wait/send tests rejecting v5-only packet types on v3.1.1 sessions. |
| tests/test_broker_connect.c | Adds broker integration tests verifying Will publication on response write failures. |
| src/mqtt_packet.c | Implements protocol-level-sensitive UNSUBACK Remaining Length validation. |
| src/mqtt_client.c | Rejects AUTH and server-sent DISCONNECT on v3.1.1 sessions; blocks AUTH send on non-v5 sessions. |
| src/mqtt_broker.c | Adds write-result normalization for direct responses and treats write failures as fatal to trigger Will. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Fixes #580 #581 #582