Test Selfdestruct Balance Bug¶
Documentation for tests/paris/security/test_selfdestruct_balance_bug.py.
Generate fixtures for these test cases with:
fill -v tests/paris/security/test_selfdestruct_balance_bug.py
Tests the Consensus Flaw During Block Processing related to SELFDESTRUCT
Tests the consensus-vulnerability reported in go-ethereum/security/advisories/GHSA-xw37-57qp-9mm4.
To reproduce the issue with this test case:
- Fill the test with the most recent geth evm version.
- Run the fixture output within a vulnerable geth version: v1.9.20 > geth >= v1.9.4.
test_tx_selfdestruct_balance_bug(blockchain_test, yul)
¶
Test that the vulnerability is not present by checking the balance of the
0xaa contract after executing specific transactions:
-
Start with contract
0xaawhich has initial balance of 3 wei.0xaacontract code simply performs a self-destruct to itself. -
Send a transaction (tx 1) to invoke caller contract
0xcc(which has a balance of 1 wei), which in turn invokes0xaawith a 1 wei call. -
Store the balance of
0xaaafter the first transaction is processed.0xaaself-destructed. Expected outcome: 0 wei. -
Send another transaction (tx 2) to call 0xaa with 5 wei.
-
Store the balance of
0xaaafter the second transaction is processed. No self-destruct. Expected outcome: 5 wei. -
Verify that:
- Call within tx 1 is successful, i.e
0xaaself-destructed. - The balances of
0xaaafter each tx are correct. - During tx 2, code in
0xaadoes not execute, hence self-destruct mechanism does not trigger.
- Call within tx 1 is successful, i.e
Source code in tests/paris/security/test_selfdestruct_balance_bug.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |