Skip to content

Broker, client, and MQTT v5 packet validation and reliability fixes#552

Open
aidangarske wants to merge 34 commits into
masterfrom
fenrir-highmed-fixes
Open

Broker, client, and MQTT v5 packet validation and reliability fixes#552
aidangarske wants to merge 34 commits into
masterfrom
fenrir-highmed-fixes

Conversation

@aidangarske

@aidangarske aidangarske commented Jun 12, 2026

Copy link
Copy Markdown
Member

Description

F-3825, F-4050, F-4051, F-4052, F-4059, F-4244, F-4245, F-4246, F-4247, F-4249, F-4304, F-4305, F-4307,
F-4308, F-4529, F-4652, F-4653, F-4654, F-4655, F-4656, F-4657, F-4658, F-4722, F-4723, F-4724, F-4726,
F-4727, F-4729, F-4772, F-4773, F-4776, F-4777, F-4928, F-4929, F-4932, F-4933, F-4991, F-4992, F-4993,
F-4994, F-4996, F-4997,  F-5115, F-5116, F-5143, F-5148, F-5149, F-5512, F-5766, F-5767, F-5768, F-5769,
F-5771, F-5861, F-5862, F-5863, F-5865, F-4725, F-5144, F-4927

…ll re-entrancy, scoped wolfSSL cleanup, fan-out write reset
…roker publish, enforce retained cap on persist restore
Copilot AI review requested due to automatic review settings June 12, 2026 17:24

This comment was marked as resolved.

wolfSSL-Fenrir-bot

This comment was marked as resolved.

@embhorn embhorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor things to clean up

Comment thread examples/firmware/fwclient.c Outdated
Comment thread scripts/broker_test/ca-cert.pem Outdated
Comment thread src/mqtt_packet.c Outdated
Comment thread tests/test_broker_connect.c Outdated
Comment thread src/mqtt_broker.c Outdated
Comment thread tests/test_mqtt_packet.c Outdated
Comment thread tests/test_mqtt_packet.c Outdated
Comment thread tests/test_broker_connect.c Outdated
Comment thread tests/test_broker_connect.c Outdated
Comment thread tests/test_mqtt_client.c Outdated
@aidangarske aidangarske requested a review from embhorn June 15, 2026 16:59

@embhorn embhorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skoll Code Review

Scan type: review
Overall recommendation: COMMENT
Findings: 5 total — 3 posted, 2 skipped
2 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [Medium] Per-client subscription cap default can be surprisingly small and silently rejects subscriptionssrc/mqtt_broker.c:2806-2812 (cap check); wolfmqtt/mqtt_broker.h:96-106 (default)
  • [Medium] MqttClient_Auth rx_buf scrub runs unlocked, racing concurrent reads in MULTITHREADsrc/mqtt_client.c:2924
  • [Low] Static fan-out: misleading comment and write attempted to a just-closed peer's other matching subsrc/mqtt_broker.c:5312-5325

Skipped findings

  • [Low] New v5 DISCONNECT-with-Will (reason 0x04) broker path has no dedicated test
  • [Low] MQTT_MAX_PROPS cap may reject spec-legal v5 messages with many User Properties

Review generated by Skoll

Comment thread src/mqtt_client.c
* delivered auth->props to the property callback and then freed them and
* set auth->props = NULL. So the bytes are consumed before this scrub and
* the caller has no live pointer into rx_buf. */
CLIENT_FORCE_ZERO(client->rx_buf, client->rx_buf_len);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [Medium] MqttClient_Auth rx_buf scrub runs unlocked, racing concurrent reads in MULTITHREAD

The new CLIENT_FORCE_ZERO(client->rx_buf, client->rx_buf_len) scrub is placed AFTER MqttClient_WaitType has returned and after lockClient was released (line ~2914), and it is not guarded by lockRecv. In a WOLFMQTT_MULTITHREAD build another thread can already be inside…

Fix: Wrap the rx_buf scrub in the receive lock in MULTITHREAD builds, mirroring the tx_buf scrub discipline.

Comment thread src/mqtt_broker.c
(void)MqttPacket_Write(&sub->client->client,
BrokerLog_Sanitize(topic), eff_qos,
(unsigned)pub.total_len);
wr = MqttPacket_Write(&sub->client->client,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 [Low] Static fan-out: misleading comment and write attempted to a just-closed peer's other matching sub

Two minor issues in the new static-memory partial-write teardown: (1) The comment states "Removal is deferred so next_sub stays valid this iteration," but next_sub only exists in the dynamic (#ifndef WOLFMQTT_STATIC_MEMORY) path; in static mode iteration advances via the…

Fix: Correct the comment and guard the fan-out match on connection liveness.

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.

4 participants