Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest #10409

Merged
merged 1 commit into from Oct 28, 2017

Conversation

practicalswift
Copy link
Contributor

The BlockTransactions deserialization code is reachable with tainted data via ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …).

The same thing applies to BlockTransactionsRequest which is reachable via "GETBLOCKTXN".

@fanquake fanquake added the Tests label May 17, 2017
@sipa
Copy link
Member

sipa commented May 18, 2017

utACK d36fe73294b57821a793cd270bb0b4365fcdba00

@TheBlueMatt
Copy link
Contributor

Maybe add CBlockHeaderAndShortTxIDs while you're at it?

@practicalswift
Copy link
Contributor Author

practicalswift commented May 23, 2017

@TheBlueMatt Good point! Adding also CBlockHeaderAndShortTxIDs was my original intention, but when doing so I encountered a long chain of linking errors which I was unable to fully resolve.

More specifically I didn't manage to create a test_test_bitcoin_fuzzy_LDADD variable (in src/Makefile.test.include) which would allow test_bitcoin_fuzzy to be built cleanly with this patch applied:

diff --git a/src/test/test_bitcoin_fuzzy.cpp b/src/test/test_bitcoin_fuzzy.cpp
index 7b52ac9..173351f 100644
--- a/src/test/test_bitcoin_fuzzy.cpp
+++ b/src/test/test_bitcoin_fuzzy.cpp
@@ -48,6 +48,7 @@ enum TEST_ID {
     CTXOUTCOMPRESSOR_DESERIALIZE,
     BLOCKTRANSACTIONS_DESERIALIZE,
     BLOCKTRANSACTIONSREQUEST_DESERIALIZE,
+    CBLOCKHEADERANDSHORTTXIDS_DESERIALIZE,
     TEST_ID_END
 };

@@ -273,6 +274,16 @@ int main(int argc, char **argv)

             break;
         }
+        case CBLOCKHEADERANDSHORTTXIDS_DESERIALIZE:
+        {
+            try
+            {
+                CBlockHeaderAndShortTxIDs bhastids;
+                ds >> bhastids;
+            } catch (const std::ios_base::failure& e) {return 0;}
+
+            break;
+        }
         default:
             return 0;
     }

Help with solving this would be appreciated!

@practicalswift
Copy link
Contributor Author

@TheBlueMatt I solved the linking issue. Fuzzing of CBlockHeaderAndShortTxIDs has been added as part of this PR! :-)

@practicalswift practicalswift changed the title [tests] Add fuzz testing for BlockTransactions (BLOCKTXN) and BlockTransactionsRequest (GETBLOCKTXN) deserialization [tests] Add fuzz testing for BlockTransactions, BlockTransactionsRequest and CBlockHeaderAndShortTxIDs deserialization May 24, 2017
@practicalswift practicalswift changed the title [tests] Add fuzz testing for BlockTransactions, BlockTransactionsRequest and CBlockHeaderAndShortTxIDs deserialization [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest deserialization May 25, 2017
@practicalswift
Copy link
Contributor Author

practicalswift commented May 25, 2017

Reverted the CBlockHeaderAndShortTxIDs deserialization commit. Couldn't create a proper test_test_bitcoin_fuzzy_LDADD in src/Makefile.test.include that would allow test_test_bitcoin_fuzzy to compile cleanly under all configuration options.

@practicalswift practicalswift force-pushed the fuzz-blocktransactions branch 2 times, most recently from d2d4c48 to 93d7e30 Compare May 25, 2017 13:51
@practicalswift practicalswift changed the title [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest deserialization [tests] Add fuzz testing for BlockTransactions, BlockTransactionsRequest and CBlockHeaderAndShortTxIDs deserialization May 25, 2017
@practicalswift
Copy link
Contributor Author

practicalswift commented May 25, 2017

Finally managed to make the version including fuzzing of CBlockHeaderAndShortTxIDs to compile cleanly under all configuration options.

This PR should be ready for review now :-)

@practicalswift
Copy link
Contributor Author

Anyone willing to review? :-)

@practicalswift
Copy link
Contributor Author

Friendly ping @TheBlueMatt or @sipa - is this one getting ready for merge? :-)

@practicalswift
Copy link
Contributor Author

@laanwj Thanks for merging the libFuzzer support (#10440) today!

This is a friendly ping about my only currently outstanding fuzzing PR.

It adds fuzzing of the remaining deserialization code that is reachable with tainted data via ProcessMessage(…, "…", vRecv [tainted], …) but not currently covered by test_bitcoin_fuzzy. More specifically it adds fuzzing of the deserialization code for BlockTransactions, BlockTransactionsRequest and CBlockHeaderAndShortTxIDs.

Do you think it might be getting ready for merge?

When this PR is merged I'll look into having command-line argument determine the type of fuzzer as suggested in #11045.

@TheBlueMatt
Copy link
Contributor

Looks good, though does the significant extra linking cause issues? See comment at #11045 (comment) indicating that at least some fuzzers may get much slower just cause of the extra binary size.

@practicalswift
Copy link
Contributor Author

practicalswift commented Oct 24, 2017

Seems like I'm unable to create a correct Makefile.test.include for this. Anyone willing to help me resolve that issue? :-)

If not I'll probably remove the CBlockHeaderAndShortTxIDs part of this PR to avoid the linking dependency order nightmare :-)

@practicalswift practicalswift changed the title [tests] Add fuzz testing for BlockTransactions, BlockTransactionsRequest and CBlockHeaderAndShortTxIDs deserialization [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest Oct 25, 2017
@practicalswift
Copy link
Contributor Author

Changed PR to only cover BlockTransactions and BlockTransactionsRequest. Hence no extra linking.

This one should be ready for merge :-)

@TheBlueMatt
Copy link
Contributor

utACK fd3a2f3

@laanwj
Copy link
Member

laanwj commented Oct 28, 2017

utACK fd3a2f3

@laanwj laanwj merged commit fd3a2f3 into bitcoin:master Oct 28, 2017
laanwj added a commit that referenced this pull request Oct 28, 2017
…kTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 22, 2019
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 2, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 4, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 16, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 22, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 29, 2020
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
@practicalswift practicalswift deleted the fuzz-blocktransactions branch April 10, 2021 19:32
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Feb 12, 2022
…nd BlockTransactionsRequest

fd3a2f3 [tests] Add fuzz testing for BlockTransactions and BlockTransactionsRequest (practicalswift)

Pull request description:

  The `BlockTransactions` deserialization code is reachable with tainted data via `ProcessMessage(…, "BLOCKTXN", vRecv [tainted], …)`.

  The same thing applies to `BlockTransactionsRequest` which is reachable via `"GETBLOCKTXN"`.

Tree-SHA512: 64560ea344bc6145b940472f99866b808725745b060dedfb315be400bd94e55399f50b982149645bd7af7ed9935fd28751d7daf0d3f94a8e2ed3bc52e3325ffb
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants