Skill 3.1.2
Identify arithmetic and access control flaws
Key Concepts
Before Solidity 0.8.0, integer arithmetic silently wrapped around: subtracting 1 from a zero uint256 produced the maximum value. Libraries such as SafeMath added checks. Since 0.8.0, overflow and underflow revert by default, and wrapping happens only inside unchecked { } blocks. Remaining arithmetic risks include unsafe downcasts (casting a uint256 to a uint8 truncates silently), division that rounds down and precision loss from dividing before multiplying.
Access control flaws occur when a sensitive function, such as mint, withdrawAll, setOwner or an initialize function, can be called by anyone, or when authorisation uses tx.origin. A malicious contract that the owner is tricked into calling sees tx.origin equal to the owner, so it passes a tx.origin check; msg.sender would correctly identify the malicious contract as the caller. Default visibility mistakes and unprotected selfdestruct or delegatecall are related flaws.