test: cover orphan reconsideration interruptibility #36262

Manually merged
ViniciusCestarii merged 1 commit from test-orphan_reconsideration_interruptible into master 2026-10-05 12:02:16 +00:00 AGit
ViniciusCestarii commented 2026-09-15 15:03:36 +00:00 (Migrated from github.com)

Add test checking that ProcessOrphanTx reconsiders at most one orphan per ProcessMessages(). This test prevents regression of CVE-2024-52914 which currently no existing test checks.

The test kills 2 mutants found with https://github.com/ViniciusCestarii/mutant-harness:

  1. Remove return true after an orphan is accepted
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3494,7 +3494,6 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
         if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
             LogDebug(BCLog::TXPACKAGES, "   accepted orphan tx %s (wtxid=%s)\n", orphanHash.ToString(), orphan_wtxid.ToString());
             ProcessValidTx(peer.m_id, porphanTx, result.m_replaced_transactions);
-            return true;
         } else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) {
  1. Remove return true after an orphan is rejected for a reason other than TX_MISSING_INPUTS
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3508,7 +3508,6 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
          state.GetResult() != TxValidationResult::TX_RESULT_UNSET)) {
                 ProcessInvalidTx(peer.m_id, porphanTx, state, /*first_time_failure=*/false);
             }
-            return true;
         }
     }
Add test checking that ProcessOrphanTx reconsiders at most one orphan per ProcessMessages(). This test prevents regression of [CVE-2024-52914](https://bitcoincore.org/en/2024/07/03/disclose-orphan-dos/) which currently no existing test checks. The test kills 2 mutants found with https://github.com/ViniciusCestarii/mutant-harness: 1. Remove `return true` after an orphan is accepted ```diff --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3494,7 +3494,6 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer) if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) { LogDebug(BCLog::TXPACKAGES, " accepted orphan tx %s (wtxid=%s)\n", orphanHash.ToString(), orphan_wtxid.ToString()); ProcessValidTx(peer.m_id, porphanTx, result.m_replaced_transactions); - return true; } else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) { ``` 2. Remove `return true` after an orphan is rejected for a reason other than `TX_MISSING_INPUTS` ```diff --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3508,7 +3508,6 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer) state.GetResult() != TxValidationResult::TX_RESULT_UNSET)) { ProcessInvalidTx(peer.m_id, porphanTx, state, /*first_time_failure=*/false); } - return true; } } ```
DrahtBot commented 2026-09-15 15:03:44 +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
ACK instagibbs, fametrano
Concept ACK enirox001

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

<!--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/36262 * Ralph review: https://git.fish.foo/bitcoin/bitcoin/pulls/36262#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 | | ---- | --------- | | ACK | [instagibbs](https://github.com/bitcoin/bitcoin/pull/36262#issuecomment-5955266888), [fametrano](https://github.com/bitcoin/bitcoin/pull/36262#issuecomment-5955625297) | | Concept ACK | [enirox001](https://github.com/bitcoin/bitcoin/pull/36262#pullrequestreview-5264203709) | 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
DrahtBot commented 2026-09-15 16:04:15 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task macOS-cross to arm64: https://github.com/bitcoin/bitcoin/actions/runs/34985864523/job/104437664650
LLM reason (✨ experimental): CI failed because the build stopped on a Clang -Wthread-safety-analysis error (mutex g_msgproc_mutex not held exclusively) in denialofservice_tests.cpp.

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-cross to arm64`: https://github.com/bitcoin/bitcoin/actions/runs/34985864523/job/104437664650</sub> <sub>LLM reason (✨ experimental): CI failed because the build stopped on a Clang `-Wthread-safety-analysis` error (mutex `g_msgproc_mutex` not held exclusively) in `denialofservice_tests.cpp`.</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>
instagibbs commented 2026-09-16 13:14:57 +00:00 (Migrated from github.com)

concept ACK

concept ACK
enirox001 (Migrated from github.com) reviewed 2026-09-21 07:53:03 +00:00
enirox001 (Migrated from github.com) left a comment

Concept ACK

Concept ACK
fametrano (Migrated from github.com) reviewed 2026-10-02 11:52:19 +00:00
fametrano (Migrated from github.com) left a comment

tACK 1ad8b857fa

I built test_bitcoin at this commit and ran the new test 20 times; it passed every time and does not depend on timing. It fails with both mutants from the description, and with both return trues removed together, which brings back the pre-#15644 behaviour of handling every orphan in one call. It also catches dropping if (processed_orphan) return true; in ProcessMessages.

One related mutant survives: removing if (m_txdownloadman.HaveMoreWork(peer.m_id)) fMoreWork = true; from ProcessMessages. Orphan processing then starts only on the peer's next poll, up to 100 ms later. The two suggestions below kill it, and the test still passes. This is a delay, not the CVE, so it is optional.

tACK 1ad8b857fa76ec5c8173fe41db2fcdd998bf3e9d I built `test_bitcoin` at this commit and ran the new test 20 times; it passed every time and does not depend on timing. It fails with both mutants from the description, and with both `return true`s removed together, which brings back the pre-#15644 behaviour of handling every orphan in one call. It also catches dropping `if (processed_orphan) return true;` in `ProcessMessages`. One related mutant survives: removing `if (m_txdownloadman.HaveMoreWork(peer.m_id)) fMoreWork = true;` from `ProcessMessages`. Orphan processing then starts only on the peer's next poll, up to 100 ms later. The two suggestions below kill it, and the test still passes. This is a delay, not the CVE, so it is optional.
fametrano (Migrated from github.com) commented 2026-10-02 11:52:20 +00:00

Return the result, so the test can check it when the parent is sent.

        return connman.ProcessMessagesOnce(peer);
Return the result, so the test can check it when the parent is sent. ```suggestion return connman.ProcessMessagesOnce(peer); ```
fametrano (Migrated from github.com) commented 2026-10-02 11:52:20 +00:00

This fails if ProcessMessages stops signalling more work once the parent is accepted.

    BOOST_CHECK(send_tx(parent));
This fails if `ProcessMessages` stops signalling more work once the parent is accepted. ```suggestion BOOST_CHECK(send_tx(parent)); ```
First-time contributor

Base: 69142eacd1374925cc9e4ea736c21fcec16307d0
Head: 16bff77a5aaf7a9740b859f74b8898cee6de5588

No verified findings are available from this partial review.

Review coverage was incomplete. The adversarial_glm review did not complete.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `69142eacd1374925cc9e4ea736c21fcec16307d0` Head: `16bff77a5aaf7a9740b859f74b8898cee6de5588` No verified findings are available from this partial review. Review coverage was incomplete. The adversarial_glm review did not complete. [Full review report](<https://review.fish.foo/traces/36262-16bff77a5aaf7a9740b859f74b8898cee6de5588-289-3.html>)
ViniciusCestarii (Migrated from github.com) reviewed 2026-10-02 12:50:44 +00:00
ViniciusCestarii (Migrated from github.com) commented 2026-10-02 12:50:44 +00:00

Thanks for the suggestion. Applied on aba1cd975c

Thanks for the suggestion. Applied on aba1cd975c1e5d3db7bb65d1e6c9cd7d918b2be4
ViniciusCestarii (Migrated from github.com) reviewed 2026-10-02 12:50:52 +00:00
ViniciusCestarii (Migrated from github.com) commented 2026-10-02 12:50:52 +00:00

Thanks for the suggestion. Applied on aba1cd975c

Thanks for the suggestion. Applied on aba1cd975c1e5d3db7bb65d1e6c9cd7d918b2be4
ViniciusCestarii commented 2026-10-02 12:53:23 +00:00 (Migrated from github.com)
Thanks for the reviews! Force-pushed aba1cd975c1e5d3db7bb65d1e6c9cd7d918b2be4 adding the suggestions on https://github.com/bitcoin/bitcoin/pull/36262#pullrequestreview-5391424947
instagibbs (Migrated from github.com) approved these changes 2026-10-02 13:19:35 +00:00
instagibbs (Migrated from github.com) left a comment
ACK aba1cd975c1e5d3db7bb65d1e6c9cd7d918b2be4
instagibbs (Migrated from github.com) commented 2026-10-02 13:19:22 +00:00

nit: you could make the children 0-fee, to avoid having to mutate scripts/witnesss

nit: you could make the children 0-fee, to avoid having to mutate scripts/witnesss
ViniciusCestarii (Migrated from github.com) reviewed 2026-10-02 15:04:44 +00:00
ViniciusCestarii (Migrated from github.com) commented 2026-10-02 15:04:44 +00:00

Good point, it reads cleaner. Done on aba1cd975c

Good point, it reads cleaner. Done on aba1cd975c1e5d3db7bb65d1e6c9cd7d918b2be4
instagibbs commented 2026-10-02 15:05:42 +00:00 (Migrated from github.com)
reACK https://github.com/bitcoin/bitcoin/pull/36262/commits/16bff77a5aaf7a9740b859f74b8898cee6de5588
ViniciusCestarii commented 2026-10-02 15:05:55 +00:00 (Migrated from github.com)
Thanks @instagibbs for the review! Force-pushed aba1cd975c1e5d3db7bb65d1e6c9cd7d918b2be4 addressing https://github.com/bitcoin/bitcoin/pull/36262#discussion_r4166080185
fametrano commented 2026-10-02 15:26:54 +00:00 (Migrated from github.com)

tACK 16bff77a5a

Re-tested: the test passes 20/20, and the HaveMoreWork mutant that survived before now fails at BOOST_CHECK(send_tx(parent)). With the 0-fee children, three orphans are accepted and three rejected for "min relay fee not met".

tACK 16bff77a5aaf7a9740b859f74b8898cee6de5588 Re-tested: the test passes 20/20, and the `HaveMoreWork` mutant that survived before now fails at `BOOST_CHECK(send_tx(parent))`. With the 0-fee children, three orphans are accepted and three rejected for "min relay fee not met".
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!36262
No description provided.