-
Notifications
You must be signed in to change notification settings - Fork 37.8k
tests: Add fuzzing harness for various PSBT related functions #17136
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
Thanks for adding fuzzing tests! However I think the PR list is getting saturated this way. Maybe it makes more sense to add these to a single PR. I suppose people will intend to review and merge them together anyway. |
@laanwj I try to separate so that fuzzers stressing a specific subsystem go in to the same PR. The reason I do that is that if the fuzzers uncover potential problems in our code base the fuzzing PR might need attention not only from This PR is a good example: this PR adds a PSBT fuzzer which means that an expert on that part of the code base (such as @achow101?) might want to take a look at any issues the fuzzer uncovers. Since I submitted this PR the PSBT fuzzer in this PR has managed to hit the following conditions which might need some investigation from a PSBT expert:
The day before submitting the PSBT fuzzer I submitted a Miniscript fuzzer (#17129) which means that Miniscript expert @sipa might want to take a look at the potential issues it manages to hit (heap out-of-bounds read in In summary I think it is a good idea to group related fuzzers in to the same PR. OTOH I'm not entirely convinced that it is a good idea to group unrelated fuzzers (such as for example the PSBT fuzzers and Miniscript fuzzers) in to the same PR in order to keep the PR list short :) diff --git a/src/psbt.cpp b/src/psbt.cpp
index fe74002e8..515410534 100644
--- a/src/psbt.cpp
+++ b/src/psbt.cpp
@@ -69,6 +69,9 @@ bool PartiallySignedTransaction::GetInputUTXO(CTxOut& utxo, int input_index) con
PSBTInput input = inputs[input_index];
int prevout_index = tx->vin[input_index].prevout.n;
if (input.non_witness_utxo) {
+ if (prevout_index >= input.non_witness_utxo->vout.size()) {
+ return false;
+ }
utxo = input.non_witness_utxo->vout[prevout_index];
} else if (!input.witness_utxo.IsNull()) {
utxo = input.witness_utxo;
@@ -259,6 +262,9 @@ bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction&
if (input.non_witness_utxo->GetHash() != prevout.hash) {
return false;
}
+ if (prevout.n >= input.non_witness_utxo->vout.size()) {
+ return false;
+ }
utxo = input.non_witness_utxo->vout[prevout.n];
} else if (!input.witness_utxo.IsNull()) {
utxo = input.witness_utxo; |
I don't think anyone but the maintainers ever cares about keeping the PR list clean. Feel free to ignore my remark, but don't expect attention from me any time soon on these then. Also, how you group them would be up to you, I just think that there should be a limit to the number of open PRs by one author, let alone similar ones. |
Concept ACK. I think the granular fuzz PRs are ok, it allows individuals from each subsystem to comment on them independently. |
These are the places where we process raw PSBT:
|
b5c8aa6
to
60af6cd
Compare
60af6cd
to
78033db
Compare
Rebased! |
78033db
to
ed94e0a
Compare
I did some fuzzing of Bitcoin. I wish this had been around back then. Concept ACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK ed94e0a 🌳
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
ACK ed94e0a167505cf46ae98beb13babc496acf1eeb 🌳
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgY6Qv6A5eczsPZ3gg2eLu1N/BofXKDUaRdN7oRm2zUQOvZXy+1uspKYs5rncZD
t2jcma6bLPYB1yYSZz1XGRpBR+I7F5f5oKVa6tig82MrDdI5HXqd4JyYn/10MvyJ
ln5hfGObv0S5xHsj8ut0wP7O6iahVtdKbTUBTSzLOsK8cZhOBYwGAhGR54i++71G
+0kdqGPUfMBkEqbcLdGSsoGpVnZ2RAHBaX4N1u9UuFhNQlnNcQu0ogR6NrgjA2zk
f6pWCSeZ1HgdAs3CpuWZupsp4jAYQ1GnVGB67Wr9swrhNAC2tZ0OaaEeFZ3KPP8J
g0OkeidMtDXY4xZME7UvqS/XVuSrvCRIdl97BVKmg1UF0IEGUcCmwZYXGIJ3F+6P
4HvmQhMy0jEL0bWtIGXhiONaRgru3iI1yJmjcjx/qvKqUAOhC+LfmCkLtMAvUjQs
q4fvyLQU4kAJz4UHSnMklnC87pJTwsCyy6gBHKvCCIbn9Uy1v90X9MKRawCxND6l
V05fe33X
=zQ9x
-----END PGP SIGNATURE-----
Timestamp of file with hash 6cb134b5529a1cecaf9838fe5e9d153f0bbc035bbfa3db1bb4b21f0dcd6aef96 -
ed94e0a
to
49f4c7f
Compare
@MarcoFalke Thanks a lot for reviewing! Feedback addressed. Please re-review :) |
re-ACK 49f4c7f 🐟 Show signature and timestampSignature:
Timestamp of file with hash |
@jonasnick You've shown interest in previous fuzzing harnesses - would you mind reviewing this one too? :) |
@practicalswift I think you mean @jonatack ? :) |
…ctions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
Oh, sorry! Same mistake again! :) Thanks for merging! |
Yep, don't hesitate to ping me, I'm for the moment only a part-time contributor and often don't see things :) |
@jonatack Thanks! :) (BTW: It has been nice to follow your Bitcoin Core activity and progression during 2019 and I really enjoyed the recent podcast interview. I hope you become a full-time contributor during 2020!) |
Thanks @practicalswift! 😍 |
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…functions Summary: 49f4c7f0699e5e19ac6e41ef5b607392dd7a2983 tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` --- Backport of Core [[bitcoin/bitcoin#17136 | PR17136]] Test Plan: cmake -GNinja .. -DENABLE_SANITIZERS="address;fuzzer" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ninja bitcoin-fuzzers ./srt/test/fuzz/psbt Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D6945
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
…ted functions 49f4c7f tests: Add fuzzing harness for various PSBT related functions (practicalswift) Pull request description: Add fuzzing harness for various PSBT related functions. **Testing this PR** Run: ``` $ CC=clang CXX=clang++ ./configure --enable-fuzz \ --with-sanitizers=address,fuzzer,undefined $ make $ src/test/fuzz/psbt ``` ACKs for top commit: MarcoFalke: re-ACK 49f4c7f 🐟 Tree-SHA512: 4cebe62bd8c244ee40a43e829f5bd175ab40e1dfbbab1affb1529374858225820d6c9fa9ba45862bf56c1522845422fd96d620cedbdec52a67ac1449dec4e1b2
Add fuzzing harness for various PSBT related functions.
Testing this PR
Run: