Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

OSS-Fuzz: Add new fuzzer/corpus/dict targets sn client - #635

Open
arthurscchan wants to merge 1 commit into
wolfSSL:masterfrom
arthurscchan:wolfmqtt-sn-client-fuzz
Open

arthurscchan wants to merge 1 commit into
wolfSSL:masterfrom
arthurscchan:wolfmqtt-sn-client-fuzz

Conversation

@arthurscchan

Copy link
Copy Markdown

This PR creates a new OSS-Fuzz fuzzer with corpus and dict targets sn client, together with google/oss-fuzz#16739 to enable a new fuzzer for improving the overall fuzzing coverage and effectiveness of proejct wolfMQTT.

Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
Copilot AI balanced review requested due to automatic review settings December 4, 2026 09:41
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Uninitialized reads, unsafe operation lifetimes, missing cleanup, and incorrect response handling and corpus fixtures undermine the fuzz harness’s safety and protocol coverage.

7 open issues
What changed in this PR

Adds MQTT-SN client fuzzing assets to wolfMQTT for integration through the companion OSS-Fuzz PR.

Changes:

  • Adds a scripted client harness with mock transport and fault injection.
  • Generates seeds for protocol exchanges and malformed inputs.
  • Provides MQTT-SN dictionary tokens to guide mutations.
File Description
tests/​fuzz/​sn.dict Adds protocol and harness dictionary tokens.
tests/​fuzz/​sn_client_fuzz.c Exercises MQTT-SN client APIs over a mock transport.
tests/​fuzz/​gen_sn_corpus.py Generates handshake, fault, and malformed-input seeds.

Review effort: Balanced

Comment on lines +125 to +127
SUBACK_OK = dg(T_SUBACK, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00)
PUBACK_QOS1 = dg(T_PUBACK, 0x00, 0x00, 0x01, 0x00) # topic id 1, pid 1
PUBACK_QOS2 = dg(T_PUBACK, 0x00, 0x00, 0x01, 0x20) # qos2: pid 1
Comment on lines +209 to +212
seeds["connect_lwt_handshake"] = flow(
[WILLTOPICREQ, WILLTOPICRESP_OK, WILLMSGREQ, WILLMSGRESP_OK,
CONNACK_OK],
[connect_op(lwt=True), willtopic_op(), willmsg_op()])
Comment on lines +143 to +144
int len;
if (!fuzz_take(p, end, &len, 1) || len < 0) {
Comment on lines +274 to +278
for (i = 0; i < FUZZ_PUMP_MAX_ITERS && rc == MQTT_CODE_CONTINUE; \
i++) { \
rc = (call); \
} \
} while (0)
mc.will.willMsgLen = (word16)will_msg_len;
}
FUZZ_PUMP(SN_Client_Connect(&g_client, &mc));
(void)SN_Client_WaitMessage(&g_client, 0);
Comment on lines +492 to +505
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
const byte* p = data;
const byte* end = data + size;
int ops = 0;
int rc;

if (size < FUZZ_MIN_INPUT_SIZE) {
return 0;
}

fuzz_net_init(&g_mock, &g_mqttNet);
XMEMSET(&g_client, 0, sizeof(g_client));
rc = MqttClient_Init(&g_client, &g_mqttNet, NULL,
}
}

(void)MqttClient_NetDisconnect(&g_client);
@embhorn

embhorn commented Dec 4, 2026

Copy link
Copy Markdown
Member

Waiting for CLA approval

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