fuzz: improve ipc fuzz coverage #35916

Open
enirox001 wants to merge 4 commits from 08-26-fuzz-ipc-coverage into master AGit
enirox001 commented 2026-08-06 13:16:39 +00:00 (Migrated from github.com)

This PR follows up on #35118 and continues the IPC fuzzing work proposed in #23015.

The initial ipc fuzz target exercised normal calls through a libmultiprocess client and server. This PR extends the target with

The raw request and response cases allow the fuzz target to exercise deserialization with data that was not first produced by libmultiprocess serialization.

The ipc setup and callback handling closely follow the existing libmultiprocess tests, particularly their use of EventLoop, ProxyClient, ProxyServer, two-way pipes, and initThreadMap.

The transaction and UniValue payload cases exercise the serialization hooks defined in common-types.h.

These files may provide useful background when reviewing the changes.

Generated coverage report after fuzzing the IPC target for a while using the qa-assets corpus.

This PR follows up on #35118 and continues the IPC fuzzing work proposed in #23015. The initial ipc fuzz target exercised normal calls through a libmultiprocess client and server. This PR extends the target with - Server side assertions that verify arguments arrive unchanged (https://github.com/bitcoin/bitcoin/pull/35118#issuecomment-4452992198 and https://github.com/bitcoin/bitcoin/pull/35118#pullrequestreview-4539477599) - A callback call that exercises ipc communication in both directions. - Raw capnp requests containing arbitrary transaction and `UniValue` payloads, which are deserialized by a normal libmultiprocess server. - Raw capnp responses containing arbitrary transaction and `UniValue` payloads, which are deserialized by a normal libmultiprocess client. The raw request and response cases allow the fuzz target to exercise deserialization with data that was not first produced by libmultiprocess serialization. The ipc setup and callback handling closely follow the existing [`libmultiprocess` tests](https://github.com/bitcoin/bitcoin/blob/master/src/ipc/libmultiprocess/test/mp/test/test.cpp), particularly their use of `EventLoop`, `ProxyClient`, `ProxyServer`, two-way pipes, and `initThreadMap`. The transaction and UniValue payload cases exercise the serialization hooks defined in [`common-types.h`](https://github.com/bitcoin/bitcoin/blob/master/src/ipc/capnp/common-types.h). These files may provide useful background when reviewing the changes. Generated [coverage report](https://enirox001.github.io/coverage/ipc/) after fuzzing the IPC target for a while using the qa-assets corpus.
DrahtBot commented 2026-08-06 13:16:48 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept ACK frankomosh, ryanofsky
Stale ACK jeanpablojp

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35932 (ipc: make ipc::disconnectIncoming wait for in-progress calls to complete by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35916 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35916.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35916#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept ACK | [frankomosh](https://github.com/bitcoin/bitcoin/pull/35916#pullrequestreview-5389939031), [ryanofsky](https://github.com/bitcoin/bitcoin/pull/35916#issuecomment-7351481035) | | Stale ACK | [jeanpablojp](https://github.com/bitcoin/bitcoin/pull/35916#pullrequestreview-4944146103) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#35932](https://github.com/bitcoin/bitcoin/pull/35932) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35932.svg"></sub> (ipc: make ipc::disconnectIncoming wait for in-progress calls to complete by ryanofsky) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
jeanpablojp (Migrated from github.com) reviewed 2026-08-15 15:40:56 +00:00
jeanpablojp (Migrated from github.com) left a comment

tACK bd24122dfbfbaded49ef551c01184b4b5b48e27f

All green, and it matches the follow-up #35118 asked for.

tACK bd24122dfbfbaded49ef551c01184b4b5b48e27f All green, and it matches the follow-up #35118 asked for.
jeanpablojp (Migrated from github.com) commented 2026-08-15 15:40:57 +00:00

Took me a bit to see why sendTransactionPayload swallows FAILED while sendUniValuePayload treats any kj error as fatal. That's correct, but you only get it by reading the hooks. A one-line comment would have helped, feel free to ignore.

                    // UniValue deserialization never throws (read() failure is ignored), so any kj error is unexpected.
                    done.set_exception(std::make_exception_ptr(
Took me a bit to see why sendTransactionPayload swallows FAILED while sendUniValuePayload treats any kj error as fatal. That's correct, but you only get it by reading the hooks. A one-line comment would have helped, feel free to ignore. ```suggestion // UniValue deserialization never throws (read() failure is ignored), so any kj error is unexpected. done.set_exception(std::make_exception_ptr( ```
enirox001 (Migrated from github.com) reviewed 2026-08-26 11:33:30 +00:00
enirox001 (Migrated from github.com) commented 2026-08-26 11:33:30 +00:00

Yes, I agree that this can be clarified a bit more, added the suggested comment to clarify why any KJ error is unexpected here. Thanks

Yes, I agree that this can be clarified a bit more, added the suggested comment to clarify why any KJ error is unexpected here. Thanks
DrahtBot commented 2026-08-26 12:34:31 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task Windows native, fuzz, VS: https://github.com/bitcoin/bitcoin/actions/runs/32963804197/job/98161775031
LLM reason (✨ experimental): CI failed because the fuzz target rpc crashed with Windows exit code 3221225477 (access violation).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Windows native, fuzz, VS`: https://github.com/bitcoin/bitcoin/actions/runs/32963804197/job/98161775031</sub> <sub>LLM reason (✨ experimental): CI failed because the fuzz target `rpc` crashed with Windows exit code `3221225477` (access violation).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
enirox001 commented 2026-08-28 07:57:25 +00:00 (Migrated from github.com)

See the generated coverage report after fuzzing the IPC target for a while using the qa-assets corpus.

Also included in the pr description

See the generated [coverage report](https://enirox001.github.io/coverage/ipc/) after fuzzing the IPC target for a while using the qa-assets corpus. Also included in the pr description
DrahtBot commented 2026-09-14 08:53:11 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-09-14 10:24:47 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task macOS native, fuzz: https://github.com/bitcoin/bitcoin/actions/runs/34830127159/job/103931261872
LLM reason (✨ experimental): CI failed because the fuzz test (fuzz target ipc) crashed with std::runtime_error: invalid JSON received over IPC (uncaught exception, exit code 1).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `macOS native, fuzz`: https://github.com/bitcoin/bitcoin/actions/runs/34830127159/job/103931261872</sub> <sub>LLM reason (✨ experimental): CI failed because the fuzz test (`fuzz` target `ipc`) crashed with `std::runtime_error: invalid JSON received over IPC` (uncaught exception, exit code 1).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
Eunovo (Migrated from github.com) reviewed 2026-09-15 09:57:44 +00:00
Eunovo (Migrated from github.com) left a comment

https://github.com/bitcoin/bitcoin/pull/35916/commits/1ea3507869869a93c136714d841fa5dd8788e8e0:

I'm not sure why random bytes are being used for CTransaction and UniValue; the chances of a randomly generated byte vector deserialising to a CTransaction are slim.

https://github.com/bitcoin/bitcoin/pull/35916/commits/1ea3507869869a93c136714d841fa5dd8788e8e0: I'm not sure why random bytes are being used for CTransaction and UniValue; the chances of a randomly generated byte vector deserialising to a CTransaction are slim.
Eunovo (Migrated from github.com) commented 2026-09-15 09:53:04 +00:00

https://github.com/bitcoin/bitcoin/pull/35916/commits/f5db59400b7838beffef3cba34d6fbcf5df9a00c:

You should use ConsumeTransaction from src/test/fuzz/util.cpp. Most of the vectors produced will be invalid.

https://github.com/bitcoin/bitcoin/pull/35916/commits/f5db59400b7838beffef3cba34d6fbcf5df9a00c: You should use `ConsumeTransaction` from `src/test/fuzz/util.cpp`. Most of the vectors produced will be invalid.
Eunovo (Migrated from github.com) commented 2026-09-15 09:53:25 +00:00
https://github.com/bitcoin/bitcoin/pull/35916/commits/f5db59400b7838beffef3cba34d6fbcf5df9a00c: Same as in my previous UniValue comment.
Eunovo (Migrated from github.com) commented 2026-09-15 09:34:45 +00:00

https://github.com/bitcoin/bitcoin/pull/35916/commits/1ea3507869869a93c136714d841fa5dd8788e8e0:

Use ConsumeTransaction in src/test/fuzz/util.cpp to create a random tx from a FuzzedDataProvider instead of using a random lenght byte vector.

https://github.com/bitcoin/bitcoin/pull/35916/commits/1ea3507869869a93c136714d841fa5dd8788e8e0: Use `ConsumeTransaction` in `src/test/fuzz/util.cpp` to create a random tx from a `FuzzedDataProvider` instead of using a random lenght byte vector.
Eunovo (Migrated from github.com) commented 2026-09-15 09:40:35 +00:00

https://github.com/bitcoin/bitcoin/pull/35916/commits/1ea3507869869a93c136714d841fa5dd8788e8e0:

Most of the generated data will be invalid JSON; this means the fuzzer will hit the "invalid JSON received over IPC" error most of the time. I think it's much better to construct a valid JSON payload, the same way we construct valid TXs with ConsumeTransaction.

https://github.com/bitcoin/bitcoin/pull/35916/commits/1ea3507869869a93c136714d841fa5dd8788e8e0: Most of the generated data will be invalid JSON; this means the fuzzer will hit the "invalid JSON received over IPC" error most of the time. I think it's much better to construct a valid JSON payload, the same way we construct valid TXs with `ConsumeTransaction`.
enirox001 (Migrated from github.com) reviewed 2026-09-16 15:57:35 +00:00
enirox001 (Migrated from github.com) commented 2026-09-16 15:57:35 +00:00

We intentionally return arbitrary transaction bytes from the raw server so the client deserialization is exercised with malformed responses.

Using ConsumeTransaction would only generate valid transactions and duplicate the existing passTransaction coverage.

I’ve added a comment clarifying the purpose of this branch.

We intentionally return arbitrary transaction bytes from the raw server so the client deserialization is exercised with malformed responses. Using `ConsumeTransaction` would only generate valid transactions and duplicate the existing passTransaction coverage. I’ve added a comment clarifying the purpose of this branch.
enirox001 (Migrated from github.com) reviewed 2026-09-16 15:57:37 +00:00
enirox001 (Migrated from github.com) commented 2026-09-16 15:57:37 +00:00

Invalid json is intentional here because it tests client side rejection of malformed ipc responses.

Valid json round trips are covered separately by passUniValue, which parses arbitrary input and proceeds when it is valid.

I’ve added a comment clarifying the distinction.

Invalid json is intentional here because it tests client side rejection of malformed ipc responses. Valid json round trips are covered separately by passUniValue, which parses arbitrary input and proceeds when it is valid. I’ve added a comment clarifying the distinction.
enirox001 (Migrated from github.com) reviewed 2026-09-16 15:59:59 +00:00
enirox001 (Migrated from github.com) commented 2026-09-16 15:59:59 +00:00

Same rationale as https://github.com/bitcoin/bitcoin/pull/35916#discussion_r4028056645: this intentionally bypasses normal serialization to exercise malformed transaction payload handling.

Same rationale as https://github.com/bitcoin/bitcoin/pull/35916#discussion_r4028056645: this intentionally bypasses normal serialization to exercise malformed transaction payload handling.
enirox001 (Migrated from github.com) reviewed 2026-09-16 16:01:26 +00:00
enirox001 (Migrated from github.com) commented 2026-09-16 16:01:26 +00:00
Same reason as https://github.com/bitcoin/bitcoin/pull/35916#discussion_r4028056893
First-time contributor

🔵 Suggestion · Transaction-request fuzz oracle accepts unrelated FAILED errors

For locally undecodable transaction bytes, the fuzz oracle would hide an unrelated remote FAILED error; no current source of such a non-decoding error was found.

Location: src/ipc/test/fuzz/ipc.cpp:171 (head).

🔵 Suggestion · Check values returned by successful raw responses

When a raw response decodes successfully, receiveTransactionPayload and receiveUniValuePayload discard the client's result: (void)m_response_client->passTransaction(request) at src/ipc/test/fuzz/ipc.cpp:238 and (void)m_response_client->passUniValue(request) at line 260. The locally decoded CTransaction tx exists only inside the probe's try block and is dropped. The target checks only whether decoding succeeds or fails as expected, not whether the client received the right value. A deserializer regression that produced a wrong but well-formed transaction or JSON value would pass.

Location: src/ipc/test/fuzz/ipc.cpp:224 (head).

Review coverage was incomplete.


Reviewed: 966457f5feaa · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:f3e06854f254c480580a263b00f5c6aaa804717e751da362d6c3a17a8fae78d3:eaa37ea1cdada8fdd806ab11180fd9e0f01062422d9d8c5ea7dcfd80d5014b95 --> <!-- ralph-base:a06515e9fdf81a762804471733b1f43a13e1f10b --> <!-- ralph-head:966457f5feaa37cd367652271eb89bbabedcbe82 --> <!-- ralph-case:2c1418e9f69f7bf6b29608356929edf4195389e95f5822f3ccf356fc2f04c26d --> **🔵 Suggestion · Transaction-request fuzz oracle accepts unrelated `FAILED` errors** For locally undecodable transaction bytes, the fuzz oracle would hide an unrelated remote `FAILED` error; no current source of such a non-decoding error was found. Location: [`src/ipc/test/fuzz/ipc.cpp:171`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/966457f5feaa37cd367652271eb89bbabedcbe82/src/ipc/test/fuzz/ipc.cpp#L171>) (head). **🔵 Suggestion · Check values returned by successful raw responses** When a raw response decodes successfully, `receiveTransactionPayload` and `receiveUniValuePayload` discard the client's result: `(void)m_response_client->passTransaction(request)` at `src/ipc/test/fuzz/ipc.cpp:238` and `(void)m_response_client->passUniValue(request)` at line 260. The locally decoded `CTransaction tx` exists only inside the probe's `try` block and is dropped. The target checks only whether decoding succeeds or fails as expected, not whether the client received the right value. A deserializer regression that produced a wrong but well-formed transaction or JSON value would pass. Location: [`src/ipc/test/fuzz/ipc.cpp:224`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/966457f5feaa37cd367652271eb89bbabedcbe82/src/ipc/test/fuzz/ipc.cpp#L224>) (head). Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`966457f5feaa`](<https://git.fish.foo/bitcoin/bitcoin/commit/966457f5feaa37cd367652271eb89bbabedcbe82>) · [Review report](<https://review.fish.foo/report/35916-966457f5feaa37cd367652271eb89bbabedcbe82-2568-5.html>) · [Previous reports](<https://review.fish.foo/traces/35916/>) [permalink](<https://review.fish.foo/report/35916-966457f5feaa37cd367652271eb89bbabedcbe82-2568-5.html>)
frankomosh (Migrated from github.com) reviewed 2026-10-02 14:01:20 +00:00
frankomosh (Migrated from github.com) left a comment

Concept ACK

Concept ACK
frankomosh (Migrated from github.com) commented 2026-10-02 08:55:08 +00:00

This might be accepting just about any server error (I believe you intend for it to accept only "bad tx bytes" errors). And could therefore hide a real server bug.

I tried a mutant on it (in ipc_fuzz.h):

-    void consumeTransaction(CTransactionRef) {}
+    void consumeTransaction(CTransactionRef) { throw std::runtime_error("unexpected"); }

Which seemingly did not crash this fuzz target.

Among the many approaches we could take to make it more effective could be to first decode the bytes locally. Then the server may only fail when the local decode fails.

Such as:

+#include <streams.h>
+
 ...
 
     void sendTransactionPayload(std::vector<uint8_t> payload)
     {
+        bool expect_ok{true};
+        if (!payload.empty()) {
+            try {
+                SpanReader reader{payload};
+                ParamsStream stream{reader, TX_WITH_WITNESS};
+                CTransaction tx{deserialize, stream};
+            } catch (const std::ios_base::failure&) {
+                expect_ok = false;
+            }
+        }
+
 ...
 
                 [&](auto&&) {
+                    if (!expect_ok) {
+                        done.set_exception(std::make_exception_ptr(
+                            std::runtime_error{"server accepted an invalid transaction"}));
+                        return;
+                    }
                     done.set_value();
                 },
                 [&](kj::Exception&& exception) {
-                    if (exception.getType() == kj::Exception::Type::FAILED) {
+                    if (!expect_ok && exception.getType() == kj::Exception::Type::FAILED) {
This might be accepting just about any server error (I believe you intend for it to accept only "bad tx bytes" errors). And could therefore hide a real server bug. I tried a mutant on it (in `ipc_fuzz.h`): ```diff - void consumeTransaction(CTransactionRef) {} + void consumeTransaction(CTransactionRef) { throw std::runtime_error("unexpected"); } ``` Which seemingly did not crash this fuzz target. Among the many approaches we could take to make it more effective could be to first decode the bytes locally. Then the server may only fail when the local decode fails. Such as: <details> <summary></summary> ```diff +#include <streams.h> + ... void sendTransactionPayload(std::vector<uint8_t> payload) { + bool expect_ok{true}; + if (!payload.empty()) { + try { + SpanReader reader{payload}; + ParamsStream stream{reader, TX_WITH_WITNESS}; + CTransaction tx{deserialize, stream}; + } catch (const std::ios_base::failure&) { + expect_ok = false; + } + } + ... [&](auto&&) { + if (!expect_ok) { + done.set_exception(std::make_exception_ptr( + std::runtime_error{"server accepted an invalid transaction"})); + return; + } done.set_value(); }, [&](kj::Exception&& exception) { - if (exception.getType() == kj::Exception::Type::FAILED) { + if (!expect_ok && exception.getType() == kj::Exception::Type::FAILED) { ``` </details>
frankomosh (Migrated from github.com) commented 2026-10-02 11:40:28 +00:00

I tried this mutant (in common-types.h), specifically to see if raw UniValue branches checks if invalid JSON is rejected. It removes the rejection completely:

-        if (!value.read(std::string_view{data.begin(), data.size()})) {
-            throw std::runtime_error{"invalid JSON received over IPC"};
-        }
+        (void)value.read(std::string_view{data.begin(), data.size()});

The fuzz target did not catch it for the corpus I generated.

One possible option of killing it is the same approach as the tx one above. I tried it, and the response-side check catches the mutant (I didn't test the request side on its own).

I tried this mutant (in `common-types.h`), specifically to see if raw UniValue branches checks if invalid JSON is rejected. It removes the rejection completely: ```diff - if (!value.read(std::string_view{data.begin(), data.size()})) { - throw std::runtime_error{"invalid JSON received over IPC"}; - } + (void)value.read(std::string_view{data.begin(), data.size()}); ``` The fuzz target did not catch it for the corpus I generated. One possible option of killing it is the same approach as the tx one above. I tried it, and the response-side check catches the mutant (I didn't test the request side on its own).
frankomosh (Migrated from github.com) reviewed 2026-10-02 14:18:45 +00:00
frankomosh (Migrated from github.com) commented 2026-10-02 14:18:45 +00:00

the chances of a randomly generated byte vector deserialising to a CTransaction are slim.

FWIW I tried to measure this and found raw bytes to reach a real tx in only under a minute, and a witness tx within a 10-minute duration of my run. I think the fuzzer does learn from coverage to build valid txs,

> the chances of a randomly generated byte vector deserialising to a CTransaction are slim. FWIW I tried to measure this and found raw bytes to reach a real tx in only under a minute, and a witness tx within a 10-minute duration of my run. I think the fuzzer does learn from coverage to build valid txs,
enirox001 (Migrated from github.com) reviewed 2026-10-09 12:11:56 +00:00
enirox001 (Migrated from github.com) commented 2026-10-09 12:11:56 +00:00

Agreed, accepting any failed error could hide an unexpected server failure.

Added the check on both the request and response sides, so ipc must succeed when the bytes decode locally and reject them when they don’t. Thanks for testing this.

Agreed, accepting any failed error could hide an unexpected server failure. Added the check on both the request and response sides, so ipc must succeed when the bytes decode locally and reject them when they don’t. Thanks for testing this.
enirox001 (Migrated from github.com) reviewed 2026-10-09 12:12:00 +00:00
enirox001 (Migrated from github.com) commented 2026-10-09 12:12:00 +00:00

The target was allowing invalid json to be accepted without failing.

Added local UniValue::read() checks on both the request and response sides, so valid json succeeds and invalid json produces the expected rejection error. Thanks

The target was allowing invalid json to be accepted without failing. Added local `UniValue::read()` checks on both the request and response sides, so valid json succeeds and invalid json produces the expected rejection error. Thanks
enirox001 commented 2026-10-09 12:13:29 +00:00 (Migrated from github.com)

Thanks for the review @frankomosh. Added local deserialization checks for transaction and UniValue payloads on both the request and response sides, so the fuzz target now fails when ipc accepts malformed data or rejects locally decodable data.

Thanks for the review @frankomosh. Added local deserialization checks for transaction and UniValue payloads on both the request and response sides, so the fuzz target now fails when ipc accepts malformed data or rejects locally decodable data.
DrahtBot commented 2026-11-10 14:02:40 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-11-12 11:16:56 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/43205413018/job/131139208283
LLM reason (✨ experimental): The build failed because fuzz target ipc.cpp cannot find the header ipc/util.h.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `test ancestor commits`: https://github.com/bitcoin/bitcoin/actions/runs/43205413018/job/131139208283</sub> <sub>LLM reason (✨ experimental): The build failed because fuzz target `ipc.cpp` cannot find the header `ipc/util.h`.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
enirox001 commented 2026-11-12 11:19:42 +00:00 (Migrated from github.com)

friendly ping @marcofleon @Crypt-iQ

friendly ping @marcofleon @Crypt-iQ
Crypt-iQ commented 2026-11-13 15:43:27 +00:00 (Migrated from github.com)

@enochaz sorry, I can't meaningfully review. I have no idea how ipc works at all at the code level. I haven't reviewed marco's ipc-mining approach but I think we both had some moderate success in fuzzamoto by simply calling random ipc methods with random values. There's currently no merged support for IPC in fuzzamoto, though I'd be happy to review a fuzzamoto IPC PR assuming it simply did something like this (calling random methods like this is really the limit of my understanding here).

@enochaz sorry, I can't meaningfully review. I have no idea how ipc works at all at the code level. I haven't reviewed marco's ipc-mining approach but *I think* we both had some moderate success in fuzzamoto by simply calling random ipc methods with random values. There's currently no merged support for IPC in fuzzamoto, though I'd be happy to review a fuzzamoto IPC PR assuming it simply did something like this (calling random methods like this is really the limit of my understanding here).
enochaz commented 2026-11-20 18:23:44 +00:00 (Migrated from github.com)

I have no idea how ipc works at all at the code level. I haven't reviewed marco's ipc-mining approach but I think we both had some moderate success in fuzzamoto by simply calling random ipc methods with random values.

Thanks @Crypt-iQ, no worries.

This target is a bit lower level than calling random ipc methods. It runs a libmultiprocess client and server in process and sends malformed transaction and json payloads in both directions, checking that ipc accepts only what decodes locally and rejects the rest.

If you have time, the accept/reject checks in sendTransactionPayload and receiveTransactionPayload might still be reviewable without much ipc background. Otherwise all good, thanks for the fuzzamoto pointer.

> I have no idea how ipc works at all at the code level. I haven't reviewed marco's ipc-mining approach but _I think_ we both had some moderate success in fuzzamoto by simply calling random ipc methods with random values. Thanks @Crypt-iQ, no worries. This target is a bit lower level than calling random ipc methods. It runs a libmultiprocess client and server in process and sends malformed transaction and json payloads in both directions, checking that ipc accepts only what decodes locally and rejects the rest. If you have time, the accept/reject checks in `sendTransactionPayload` and `receiveTransactionPayload` might still be reviewable without much ipc background. Otherwise all good, thanks for the fuzzamoto pointer.
ryanofsky commented 2026-12-02 16:07:42 +00:00 (Migrated from github.com)

Concept ACK (966457f5fe) on focusing this on the types the Mining and Chain interfaces actually pass. The type-conversion layer is where in-process fuzz tests are most useful: several real IPC bugs were values the C++ side could never produce arriving over the wire, like a CFeeRate with a negative size (#36816), a NaN read into a duration, or an out-of-range enum. Bugs involving object lifetimes, threads or disconnects are less likely to be found this way, and hard to reproduce when they are, because the fuzzer doesn't control which thread runs when. Those need tests that do control the schedule, either with hooks that pause calls at chosen points (as some libmultiprocess unit tests already do) or with a deterministic scheduler like Antithesis.

For each type the Mining and Chain interfaces pass, I think it would be good to cover:

  • Round trips: the server-side checks that values arrive unchanged (as @sedited suggested in #35118 (review)). They catch conversions that lose or change valid values.
  • Raw payloads: bytes that skip normal serialization, checking that invalid ones are rejected cleanly. These catch readers that accept values the C++ side couldn't produce.
  • Both directions: besides requests and responses, callback arguments go through their own generated code, with the server building the parameters and the client reading them. Chain's notification callbacks send transactions and block data this way. So instead of passing only an int, the callback case could pass the same types, which covers the conversions in that direction too without much extra work for the fuzzer.
Concept ACK (966457f5feaa37cd367652271eb89bbabedcbe82) on focusing this on the types the Mining and Chain interfaces actually pass. The type-conversion layer is where in-process fuzz tests are most useful: several real IPC bugs were values the C++ side could never produce arriving over the wire, like a `CFeeRate` with a negative size (#36816), a NaN read into a duration, or an out-of-range enum. Bugs involving object lifetimes, threads or disconnects are less likely to be found this way, and hard to reproduce when they are, because the fuzzer doesn't control which thread runs when. Those need tests that do control the schedule, either with hooks that pause calls at chosen points (as some libmultiprocess unit tests already do) or with a deterministic scheduler like Antithesis. For each type the Mining and Chain interfaces pass, I think it would be good to cover: - **Round trips:** the server-side checks that values arrive unchanged (as @sedited suggested in [#35118 (review)](https://github.com/bitcoin/bitcoin/pull/35118#pullrequestreview-4539477599)). They catch conversions that lose or change valid values. - **Raw payloads:** bytes that skip normal serialization, checking that invalid ones are rejected cleanly. These catch readers that accept values the C++ side couldn't produce. - **Both directions:** besides requests and responses, callback arguments go through their own generated code, with the server building the parameters and the client reading them. Chain's notification callbacks send transactions and block data this way. So instead of passing only an `int`, the callback case could pass the same types, which covers the conversions in that direction too without much extra work for the fuzzer.
maflcko commented 2026-12-02 19:49:18 +00:00 (Migrated from github.com)
cross-ref to https://github.com/bitcoin/bitcoin/issues/37063
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35916
No description provided.