-
Notifications
You must be signed in to change notification settings - Fork 375
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
Add iavl test proving forgery #583
Add iavl test proving forgery #583
Conversation
Won't compile yet. Is a test of the iavl proof forgery as exploited during BSC 2022-10-07 hack. Notes: 1. proof_forgery_test.go comes from cosmos/iavl#582 2. gist showing the same vuln at https://gist.github.com/samczsun/8635f49fac0ec66a5a61080835cae3db The test is not going to compile as is, it needs some work.
…lnerable) output follows --- FAIL: TestProofForgery (0.00s) proof_forgery_test.go:69: Error Trace: /home/bob/opt/src/COINS/Cosmos/GNO/gno/pkgs/iavl/proof_forgery_test.go:69 Error: Should be empty, but was [73 209 82 89 222 179 131 99 170 27 180 58 80 20 211 (...) 94 7 254 45 183 20 244] Test: TestProofForgery Messages: roothash must be empty if both left and right are set FAIL FAIL command-line-arguments 0.003s FAIL
Original fix at cosmos/iavl#582, is simply: ``` if len(pin.Left) > 0 && len(pin.Right) > 0 { return nil, errors.New("both left and right child hashes are set") } ``` Our iavl functions however don't return errors. Proposing to use `panic()` instead, as it does in other parts of this file. More about this 2022-10-07 vuln: https://medium.com/@Beosin_com/how-did-the-bnb-chain-exploiter-pass-iavl-proof-verification-an-in-depth-analysis-by-beosin-c925b77bc13e https://twitter.com/buchmanster/status/1578879225574350848
After applying #584 test fails, this time with:
|
Would like to use Edit: it's not ready for review yet. Test needs reorganization. |
and fails otherwise (fails when vuln not fixed) It should now be ok for review.
It should be ready for review. |
I think it's more convenient to have the test in #584, for CI sake. |
Original fix at cosmos/iavl#582, is simply: ``` if len(pin.Left) > 0 && len(pin.Right) > 0 { return nil, errors.New("both left and right child hashes are set") } ``` Our iavl functions however don't return errors. Proposing to use `panic()` instead, as it does in other parts of this file. More about this 2022-10-07 vuln: https://medium.com/@Beosin_com/how-did-the-bnb-chain-exploiter-pass-iavl-proof-verification-an-in-depth-analysis-by-beosin-c925b77bc13e https://twitter.com/buchmanster/status/1578879225574350848
and fails otherwise (fails when vuln not fixed) It should now be ok for review.
This is a fix for the 2022-10-07 Binance vuln demonstrated in #583. **Original fix** was simply (cosmos/iavl#582): ``` if len(pin.Left) > 0 && len(pin.Right) > 0 { return nil, errors.New("both left and right child hashes are set") } ``` Our iavl functions however don't return errors. Proposing to use `panic()` instead, as it does in other parts of this file. --- More about the vuln, for comments and archival: * https://twitter.com/buchmanster/status/1578879225574350848 * https://medium.com/@Beosin_com/how-did-the-bnb-chain-exploiter-pass-iavl-proof-verification-an-in-depth-analysis-by-beosin-c925b77bc13e --------- Co-authored-by: grepsuzette <grepsuzette@users.noreply.github.com> Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
This is a fix for the 2022-10-07 Binance vuln demonstrated in gnolang#583. **Original fix** was simply (cosmos/iavl#582): ``` if len(pin.Left) > 0 && len(pin.Right) > 0 { return nil, errors.New("both left and right child hashes are set") } ``` Our iavl functions however don't return errors. Proposing to use `panic()` instead, as it does in other parts of this file. --- More about the vuln, for comments and archival: * https://twitter.com/buchmanster/status/1578879225574350848 * https://medium.com/@Beosin_com/how-did-the-bnb-chain-exploiter-pass-iavl-proof-verification-an-in-depth-analysis-by-beosin-c925b77bc13e --------- Co-authored-by: grepsuzette <grepsuzette@users.noreply.github.com> Co-authored-by: Antonio Navarro Perez <antnavper@gmail.com> Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
This is a test of the iavl proof forgery as exploited during BSC 2022-10-07 hack.
proof_forgery_test.go
comes from cosmos/iavl#582Because of the discrepancy with gno/pkgs/iavl, it was adapted to compile.
Test now compiles, and fails the test as expected (-> vulnerable).
Output of
go test pkgs/iavl/proof_forgery_test.go
follows:A fix is coming.