Syntactically invalid txdata is generated for some solc
See original GitHub issueDescription
Generated txdata cannot be sometimes properly decoded for some solc. In the below example, I obtained a valid input using solc 0.5.12. But I obatined an invalid input not solc 0.4.25, which cannot be properly decoded using off-the-shelf abi decoder.
In the below examples, you can see that, for example, the input
fields in the last steps for each output have quite different lengths, though the contract used for testing is the same.
In the output1 (used solc 0.5.12),
0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000
this input value can be successfully decoded using the abi decoder in here: https://github.com/miguelmota/ethereum-input-data-decoder
However, in the output2 (used solc 0.4.25),
0x82668f20666666666666666666666666666666666666666666666666666666666666660a
now we have much shorter input value, which cannot be decoded using the abi decoder above. Specifically, it produces a mesage: insufficient data for uint256 type
. So I guess Mythril may have generated the syntactically invalid input.
How to Reproduce
Testing program:
contract Test{
uint n;
constructor (uint _n) public {
require (_n==1);
n = _n;
}
function test (uint8 a, uint[] memory b) public {
require (a==10);
n--;
}
}
Command1 (that generates valid txdata):
sudo docker exec CONTAINER_NAME myth analyze /tmp/test.sol --solv 0.5.12 -m integer,exceptions -o json
Output1 for Command1 (simplified):
'steps': [{'address': '',
'calldata': '00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'input': '0x608060405234801561001057600080fd5b506040516101b83803806101b88339818101604052602081101561003357600080fd5b81019080805190602001909291905050506001811461005157600080fd5b8060008190555050610150806100686000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806382668f2014610030575b600080fd5b6100f36004803603604081101561004657600080fd5b81019080803560ff1690602001909291908035906020019064010000000081111561007057600080fd5b82018360208201111561008257600080fd5b803590602001918460208302840111640100000000831117156100a457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506100f5565b005b600a8260ff161461010557600080fd5b600080815480929190600190039190505550505056fea265627a7a72315820bb01cda6ba4124fde44870a05970c0990509bdf9da47ca0bc0a3f8d8be43907c64736f6c634300050c003200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
'name': 'unknown',
'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
'value': '0x0'},
{'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
'calldata': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
'input': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
'name': 'test(uint8,uint256[])',
'origin': '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'value': '0x0'},
{'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
'calldata': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
'input': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
'name': 'test(uint8,uint256[])',
'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
'value': '0x0'}]}}],
'success': True}
Command2 (that generates invalid txdata):
sudo docker exec CONTAINER_NAME myth analyze /tmp/test.sol --solv 0.4.25 -m integer,exceptions -o json
where the only difference is the provided --solv option.
Output2 for Command2 (simplified):
'steps': [{'address': '',
'calldata': '0000000000000000000000000000000000000000000000000000000000000001',
'input': '0x608060405234801561001057600080fd5b506040516020806101608339810180604052810190808051906020019092919050505060018114151561004257600080fd5b8060008190555050610107806100596000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806382668f20146044575b600080fd5b348015604f57600080fd5b5060b2600480360381019080803560ff1690602001909291908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929050505060b4565b005b600a8260ff1614151560c557600080fd5b60008081548092919060019003919050555050505600a165627a7a723058203afae6d203291064d5f94ced7ff9c6a3567929d136ffa919f2e3b5fdcd569c7900290000000000000000000000000000000000000000000000000000000000000001',
'name': 'unknown',
'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
'value': '0x0'},
{'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
'calldata': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
'input': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
'name': 'test(uint8,uint256[])',
'origin': '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'value': '0x0'},
{'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
'calldata': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
'input': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
'name': 'test(uint8,uint256[])',
'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
'value': '0x0'}]}}],
'success': True}
Expected behavior
Valid txdata should be generated for any solc.
Environment
- Mythril version: v 0.21.21 (from docker image)
- Solidity compiler and version: 0.5.12
- Python version: 3.6.9 (the one installed in the docker container)
- OS and Version: Ubuntu 18.04 (Host OS)
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top GitHub Comments
Oh! sorry about that. Mythril doesn’t 0 pad the end, that might be the problem for the error with the ABI decoder.
@norhh Thank you very much!