Repository navigation
OSS-Fuzz: Add new fuzzer/corpus/dict targets sn client - #635
Open
arthurscchan wants to merge 1 commit into
Open
arthurscchan wants to merge 1 commit into
arthurscchan wants to merge 1 commit into
Conversation
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
|
Can one of the admins verify this patch? |
There was a problem hiding this comment.
🟡 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
Correct SUBACK and PUBACK fixtures and use PUBREC for QoS 2 · New Queue Will update responses immediately before their operations · New Read fuzzed length into a byte-sized variable · New Keep operations alive when the execution cap expires · New Avoid implicit waits that consume the next operation's response · New Register a successful callback to exercise inbound QoS handling · New Deinitialize the client after disconnecting · New
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); |
Member
|
Waiting for CLA approval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.