Smart contract vulnerabilities (Re-entrance, Arithmetic overflow and underflow, Accessing private data)

Overflow & Underflow

1. Choose Overflow or Underflow from the given options.

overflow-underflow

2. Select the data type as uint8.

overflow-underflow

3. Enter a value greater than 255.

overflow-underflow

4. Click the Help button to see the explanation.

overflow-underflow

5. Click the Underflow button and select a data type.

overflow-underflow

6. Enter a value less than 0.

overflow-underflow

7. Click the Help button to see the explanation.

overflow-underflow

8. Click the Show Example button to view an example of overflow.

overflow-underflow

9. Enter an amount greater than the sender’s balance.

overflow-underflow

10. Click the Transfer button to see an overflow alert message.

overflow-underflow

11. Enter a negative amount.

overflow-underflow

12. Click the Transfer button.

Re-entrancy

Click on the attack button and observe the changes happening carefully.

re-entrancy

Step 1: The attack() function deposits 1 ETH into the Bank contract.

re-entrancy

Step 2: The attack() function deposits 1 ETH into the Bank contract.

re-entrancy

Step 3: Since the balance of msg.sender (the Attack contract's address) is greater than 0, an external contract is called to send the value.

re-entrancy

Step 4: When the Attack contract receives ETH from the Bank contract, the fallback() function is called. First, it checks the balance in the Bank contract, then it calls the withdraw() function in the Bank contract again.

re-entrancy

Step 5: The line balances[msg.sender] = 0 is not reached because msg.sender.call has not finished yet. This continues until all the funds in the Bank contract are drained.

re-entrancy