Code and slides of ICT Risk Assessment 2018/2019 seminar.
NEW! Now compatible with Solidity 0.5.1!
Design patterns are a commonly used technique to encode design guide-lines or best practices. They express an abstract or conceptual solution to a concrete, complex, and reoccurring problem.
_
CHECKS-EFFECTS-INTERACTION PATTERN
Problem
When a contract calls another contract, it hands over control to that other contract. The called contract can then, in turn, re-enter the contract by which it was called and try to manipulate its state or hijack the control flow through malicious code.
Solution
Follow a recommended functional code order, in which calls to external contracts are always the last step, to reduce the attack surface of a contract being manipulated by its own externally called contracts.
Since a deployed contract is executed autonomously on the Ethereum network, there is no option to halt its execution in case of a major bug or security issue.
Solution
Incorporate an emergency stop functionality into the contract that can be triggered by an authenticated party to disable sensitive functions.