State-of-the-art about program verification on Ethereum DApps
Solidity
22
18 commits
updated Dec 6, 2023
a new systematic characterization of a class of trace vulnerabilities, which result from analyzing multiple invocations of a contract over its lifetime
three example properties of such trace vulnerabilities:
Greedy: lock funds indefinitely,
Prodigal (very generous, recklessly wasteful): leak ether carelessly to arbitrary users, or
Suicidal: can be killed by anyone.
id' is an indocile contract, selfdestruct(id') will send suicide's remaining ether to id'. In other words, any contract can't prevent Ether accepting. Or we say, we can use selfdestruct(id') to send Ether to any contract.Several platforms for smart contracts have been proposed, and this paper have analyzed the usage of smart contracts from various perspectives. Mainly, by manually analyzing 834 smart contracts from Ethereum (811, verified) and Bitcoin (23), it concludes 5 categories describing smart contracts intended application domain, and 9 design patterns. Among these, they observe that token, authorization, time constraint, and termination are generally the most used patterns. Also, they give the quantitative results in details.
Another contribution is the analysis of platforms. At first, they drew up a candidate list, 12 platforms, by examining all 175 articles of coindesk.com in "smart contracts" category by Sept 15, 2016. Then ruled out half of them by 3 criteria:
They get the sample of 6 platforms (Bitcoin, Ethereum, Counterparty, Stellar, Monax and Lisk), and give the results, mainly considering blockchain types, contract languages, transaction amount and market shares.
5 categories:
9 design patterns:
Good survey, helpful to beginners. However, it didn't analyze DSL or VM used for smart contracts. For example, high-level languages like Solidity or Viper, and low-level virtual machines like EVM or IELE. Also, some platforms claim they support
"To our knowledge, ours is the first formal EVM definition for smart contract verification that implements all instructions. Our definition can serve as a basis for further analysis and generation of Ethereum smart contracts."
In this paper we provide the first systematic exposition of the security vulnerabilities of Ethereum and of its high-level programming language, Solidity.
0x3af39c21 in data field.Currently, types of vulnerabilities can be divided as 3 main categories: external calling, internal execution and blockchain limitation.
Several tools to detect bugs
inter-procedural, trigger + modules
Intra-procedural
czc@vultr:~/manticore/examples/linux$ manticore basic
2018-01-30 16:48:42,626: [7231] m.manticore:INFO: Loading program basic
2018-01-30 16:48:52,257: [7231] m.manticore:INFO: Generated testcase No. 0 - Program finished with exit status: 0
2018-01-30 16:48:53,831: [7231] m.manticore:INFO: Generated testcase No. 1 - Program finished with exit status: 0
2018-01-30 16:48:53,834: [7231] m.manticore:INFO: Results in /home/czc/manticore/examples/linux/mcore_t9BiJE
2018-01-30 16:48:53,834: [7231] m.manticore:INFO: Total time: 9.56235694885
czc@vultr:~/manticore/examples/linux$ cat mcore_t9BiJE/test_00000000.stdin | ./basic
Message: It is greater than 0x41
czc@vultr:~/manticore/examples/linux$ cat mcore_t9BiJE/test_00000001.stdin | ./basic
Message: It is less than or equal to 0x41
czc@vultr:~/manticore/examples/script$ python count_instructions.py ../linux/helloworld
Executed 6266 instructions.
Reversing and bug hunting framework for the Ethereum blockchain (described in Ethereum Smart Contract Best Practices)
Documentation mythril 0.14.9
Install
libssl-devpython3 -m venv ./ in a test directory, then cd bin and source activate.Note
Introducing Mythril: A framework for bug hunting on the Ethereum blockchain by Bernhard Mueller, a security engineer at ConsenSys.
full node needs or use infura
In this article, I’ll show how to run different types of security scans with Mythril using smart contracts from the Ethernaut wargame as examples (thanks to the guys from Zeppelin solutions for giving me permission). If you haven’t tried the wargame yourself, be aware that there are spoilers ahead! I recommend giving it a shot yourself first if you haven’t already.
A Solidity parser in Javascript. So we can evaluate and alter Solidity code without resorting to cruddy preprocessing.
opam, modify the PATH and wait opam init for a long time (about an hour).SmartCheck: Static Code Analyzer
We have built our own static code analyzer for Solidity. Our full analysis includes complete manual analysis and verification of all the issues reported by SmartCheck.
####Vyper online
pip install vyper, Python 3 required.vyper-run: support some features as hevm.echo -n $(cat your.bin-runtime) > true.bin-runtimecat true.bin-runtime | evmdis > your.disasmNotes:
--code is mandatory. --abi is optional but recommended.--cfg can generate dot code for contract's CFG. Save the output as file.dot then dot file.dot -Tpdf -o image.pdf to get the image (Install graphviz: sudo apt-get install graphviz). Among -Tps, -Tpng and -Tpdf, -Tpdf is the best.Install
abi=$(cat ./output/SendBalance.abi)-- code can be followed by $bin or $binRuntime.Problems/issues:
Some try:
vulnerable.sol but failed, too.parse: Please at least provide some byte code (--code) or run it in debug mode (--debug) with pre-configured inputs.
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <support@comae.io>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Usage: porosity [options]
Debug:
--debug - Enable debug mode. (testing only - no input parameter needed.)
Input parameters:
--code <bytecode> - Ethereum bytecode. (mandatory)
--code-file <filename> - Read ethereum bytecode from file
--arguments <arguments> - Ethereum arguments to pass to the function. (optional, default data set provided if not provided.)
--abi <arguments> - Ethereum Application Binary Interface (ABI) in JSON format. (optional but recommended)
--hash <hashmethod> - Work on a specific function, can be retrieved wit --list. (optional)
Features:
--list - List identified methods/functions.
--disassm - Disassemble the bytecode.
--single-step - Execute the byte code through our VM.
--cfg - Generate a the control flow graph in Graphviz format.
--cfg-full - Generate a the control flow graph in Graphviz format (including instructions)
--decompile - Decompile a given function or all the bytecode.
Framework for serverless Decentralized Applications using Ethereum, IPFS and other platforms
State-of-the-art about program verification on Ethereum DApps
Solidity
22
18 commits
updated Dec 6, 2023
a new systematic characterization of a class of trace vulnerabilities, which result from analyzing multiple invocations of a contract over its lifetime
three example properties of such trace vulnerabilities:
Greedy: lock funds indefinitely,
Prodigal (very generous, recklessly wasteful): leak ether carelessly to arbitrary users, or
Suicidal: can be killed by anyone.
id' is an indocile contract, selfdestruct(id') will send suicide's remaining ether to id'. In other words, any contract can't prevent Ether accepting. Or we say, we can use selfdestruct(id') to send Ether to any contract.Several platforms for smart contracts have been proposed, and this paper have analyzed the usage of smart contracts from various perspectives. Mainly, by manually analyzing 834 smart contracts from Ethereum (811, verified) and Bitcoin (23), it concludes 5 categories describing smart contracts intended application domain, and 9 design patterns. Among these, they observe that token, authorization, time constraint, and termination are generally the most used patterns. Also, they give the quantitative results in details.
Another contribution is the analysis of platforms. At first, they drew up a candidate list, 12 platforms, by examining all 175 articles of coindesk.com in "smart contracts" category by Sept 15, 2016. Then ruled out half of them by 3 criteria:
They get the sample of 6 platforms (Bitcoin, Ethereum, Counterparty, Stellar, Monax and Lisk), and give the results, mainly considering blockchain types, contract languages, transaction amount and market shares.
5 categories:
9 design patterns:
Good survey, helpful to beginners. However, it didn't analyze DSL or VM used for smart contracts. For example, high-level languages like Solidity or Viper, and low-level virtual machines like EVM or IELE. Also, some platforms claim they support
"To our knowledge, ours is the first formal EVM definition for smart contract verification that implements all instructions. Our definition can serve as a basis for further analysis and generation of Ethereum smart contracts."
In this paper we provide the first systematic exposition of the security vulnerabilities of Ethereum and of its high-level programming language, Solidity.
0x3af39c21 in data field.Currently, types of vulnerabilities can be divided as 3 main categories: external calling, internal execution and blockchain limitation.
Several tools to detect bugs
inter-procedural, trigger + modules
Intra-procedural
czc@vultr:~/manticore/examples/linux$ manticore basic
2018-01-30 16:48:42,626: [7231] m.manticore:INFO: Loading program basic
2018-01-30 16:48:52,257: [7231] m.manticore:INFO: Generated testcase No. 0 - Program finished with exit status: 0
2018-01-30 16:48:53,831: [7231] m.manticore:INFO: Generated testcase No. 1 - Program finished with exit status: 0
2018-01-30 16:48:53,834: [7231] m.manticore:INFO: Results in /home/czc/manticore/examples/linux/mcore_t9BiJE
2018-01-30 16:48:53,834: [7231] m.manticore:INFO: Total time: 9.56235694885
czc@vultr:~/manticore/examples/linux$ cat mcore_t9BiJE/test_00000000.stdin | ./basic
Message: It is greater than 0x41
czc@vultr:~/manticore/examples/linux$ cat mcore_t9BiJE/test_00000001.stdin | ./basic
Message: It is less than or equal to 0x41
czc@vultr:~/manticore/examples/script$ python count_instructions.py ../linux/helloworld
Executed 6266 instructions.
Reversing and bug hunting framework for the Ethereum blockchain (described in Ethereum Smart Contract Best Practices)
Documentation mythril 0.14.9
Install
libssl-devpython3 -m venv ./ in a test directory, then cd bin and source activate.Note
Introducing Mythril: A framework for bug hunting on the Ethereum blockchain by Bernhard Mueller, a security engineer at ConsenSys.
full node needs or use infura
In this article, I’ll show how to run different types of security scans with Mythril using smart contracts from the Ethernaut wargame as examples (thanks to the guys from Zeppelin solutions for giving me permission). If you haven’t tried the wargame yourself, be aware that there are spoilers ahead! I recommend giving it a shot yourself first if you haven’t already.
A Solidity parser in Javascript. So we can evaluate and alter Solidity code without resorting to cruddy preprocessing.
opam, modify the PATH and wait opam init for a long time (about an hour).SmartCheck: Static Code Analyzer
We have built our own static code analyzer for Solidity. Our full analysis includes complete manual analysis and verification of all the issues reported by SmartCheck.
####Vyper online
pip install vyper, Python 3 required.vyper-run: support some features as hevm.echo -n $(cat your.bin-runtime) > true.bin-runtimecat true.bin-runtime | evmdis > your.disasmNotes:
--code is mandatory. --abi is optional but recommended.--cfg can generate dot code for contract's CFG. Save the output as file.dot then dot file.dot -Tpdf -o image.pdf to get the image (Install graphviz: sudo apt-get install graphviz). Among -Tps, -Tpng and -Tpdf, -Tpdf is the best.Install
abi=$(cat ./output/SendBalance.abi)-- code can be followed by $bin or $binRuntime.Problems/issues:
Some try:
vulnerable.sol but failed, too.parse: Please at least provide some byte code (--code) or run it in debug mode (--debug) with pre-configured inputs.
Porosity v0.1 (https://www.comae.io)
Matt Suiche, Comae Technologies <support@comae.io>
The Ethereum bytecode commandline decompiler.
Decompiles the given Ethereum input bytecode and outputs the Solidity code.
Usage: porosity [options]
Debug:
--debug - Enable debug mode. (testing only - no input parameter needed.)
Input parameters:
--code <bytecode> - Ethereum bytecode. (mandatory)
--code-file <filename> - Read ethereum bytecode from file
--arguments <arguments> - Ethereum arguments to pass to the function. (optional, default data set provided if not provided.)
--abi <arguments> - Ethereum Application Binary Interface (ABI) in JSON format. (optional but recommended)
--hash <hashmethod> - Work on a specific function, can be retrieved wit --list. (optional)
Features:
--list - List identified methods/functions.
--disassm - Disassemble the bytecode.
--single-step - Execute the byte code through our VM.
--cfg - Generate a the control flow graph in Graphviz format.
--cfg-full - Generate a the control flow graph in Graphviz format (including instructions)
--decompile - Decompile a given function or all the bytecode.
Framework for serverless Decentralized Applications using Ethereum, IPFS and other platforms