Solidity Security Vulnerabilities: Denial Of Service (DOS)

These attacks can leave a contract inoperable either temporarily or permanently. There are many ways a contract can become inoperable; some are presented below: External function calls: An external function may maliciously use all gas when called, making a contract temporarily or even permanently inoperable. For example, the TrickleWallet at issues a function call … Read more

Solidity Security Vulnerabilities: Unchecked Return Values

We can use .transfer() to send Ether which is considered safe as it reverts in case the transfer fails. We can also use .send() and .call() to transfer Ether but they only return a value of false if they fail. This creates a security vulnerability where an attacker can target a transaction that should have … Read more

Solidity Security Vulnerabilities: Short Address/Parameter Attack

Prior to Solidity v0.5.0, Smart Contracts suffered from vulnerability resulting from attacker using a shorter than required address as function parameter. The vulnerability resulted from EVM’s tendency to append zero’s at the end of calldata in case a parameter(in this case, an address) was shorter in length than it is by definition. Looking at example … Read more

Solidity Security Vulnerabilities: Entropy Illusion

There is no random() function in Solidity so the developers end up using other means of achieving randomness such as using hash of next block as a random value. If this source of entropy is not selected carefully, it can be used by an attacker to predict the next “random” value and exploit a contract.

Solidity Security Vulnerabilities: Default Visibility

Earlier version of solidity did not enforce defining visibility on functions. This created situations where an attacker would be able to call a function that he/she shouldn’t be. Recent Solidity versions enforce setting up visibility on every function so this vulnerability has been mitigated. However it is still important to review the visibility of all … Read more

Solidity Security Vulnerabilities: DelegateCall

There are two kinds of low level functions invocations: call() and delegatecall(). The latter is used when we wish to execute an external function in the context of the caller contract. This means the target function can manipulate the state variables of the caller contract. So, if contract A issues a delegatecall to, then … Read more

Solidity Security Vulnerabilities: Unexpected Ether

A contract may be vulnerable if it incorrectly uses address(this).balance. I modified the EtherGame contract from wrote the Player and Attacker contact to demonstrate this vulnerability. How to Test: Deploy EtherGame and note the contract’s address Deploy the Player contract with 5 Ether and pass the address of EtherGame’s address to the constructor Deploy … Read more

Solidity Security Vulnerabilities: Arithmetic Over/Under Flows

Prior to v0.8.1, Solidity contracts were vulnerable to over/underflow attacks. This vulnerability caused mathematical operations of +, – and * to be exploited if the attacker can control the value of at least one operand. A demo for over/underflow behaviour is provided below: To see the vulnerability in action, lets see the contract from one … Read more