Blockchain Security Training Smart Contract Exploit Analysis 3 — Questions and Answers
Question 1: Before Solidity 0.8.0, an unchecked addition that exceeds uint256 max would:
- Wrap around to a small number (overflow) (Correct answer)
- Revert automatically
- Throw a compile error
- Return the max value
Correct answer: Wrap around to a small number (overflow)
Pre-0.8.0 arithmetic wrapped silently on overflow, enabling balance manipulation exploits.
Question 2: How does Solidity 0.8.0+ handle integer overflow and underflow by default?
- Reverts the transaction on over/underflow (Correct answer)
- Wraps silently
- Logs a warning only
- Caps at the type's limit
Correct answer: Reverts the transaction on over/underflow
Solidity 0.8.0 introduced built-in checked arithmetic that reverts on overflow/underflow.
Question 3: What is the security risk of wrapping arithmetic in an `unchecked { }` block in Solidity 0.8+?
- It disables overflow/underflow protection inside the block (Correct answer)
- It makes the code non-payable
- It forces a revert on any math
- It prevents external calls
Correct answer: It disables overflow/underflow protection inside the block
The `unchecked` block restores wrapping behavior, reintroducing overflow risk if used carelessly.
Question 4: An underflow in a token balance subtraction (balance -= amount) before checks could let an attacker:
- Obtain a massive balance from a small one (Correct answer)
- Freeze the contract permanently
- Drain only their own funds
- Change the owner address
Correct answer: Obtain a massive balance from a small one
Underflowing a subtraction below zero wraps to near uint256 max, granting an enormous fake balance.
Question 5: Which library was historically used to add overflow protection before Solidity 0.8?
- SafeMath (Correct answer)
- SafeERC20
- Ownable
- Address
Correct answer: SafeMath
OpenZeppelin's SafeMath provided checked add/sub/mul/div that reverted on overflow.
Question 6: The 2018 BeautyChain (BEC) batchTransfer exploit was caused by:
- A multiplication overflow inflating transfer amounts (Correct answer)
- A reentrancy loop
- A delegatecall to attacker code
- A signature replay
Correct answer: A multiplication overflow inflating transfer amounts
An overflow in `amount * receivers.length` produced huge balances minted to attackers.
Question 7: Casting a uint256 down to uint8 without validation can introduce what bug?
- Silent truncation of the high bits (Correct answer)
- A guaranteed revert
- A gas refund
- A reentrancy window
Correct answer: Silent truncation of the high bits
Narrowing casts drop high-order bits, so a large value can become an unexpectedly small one.
Before Solidity 0.8.0, an unchecked addition that exceeds uint256 max would: