List: 100 Assumptions That Could Lead to Bugs
List: 100 Assumptions That Could Lead to Bugs
I’ve been getting questions about assumptions vs invariants, since the following tweet:
ChatGPT provided, surprisingly, a good list (not exhaustive by any means of course but the coverage is quite wide and can give some nice ideas):
1. Input-Related Assumptions
- Users will not pass zero as an input.
- Users will not pass maximum integer values.
- Negative numbers are not possible as inputs.
- Input arrays will always have unique elements.
- Input strings will not be excessively large.
- Addresses provided will not be zero address.
- Addresses provided will not be the contract’s own address.
- Token amounts will not exceed the balance of the sender.
- Token amounts will not exceed the allowance provided.
- Numeric inputs will not cause overflows or underflows.
- Users will not use uninitialized or invalid token contracts.
- Users will provide valid enum values.
- Nonces will always increase as intended.
- Inputs will match expected types (e.g., ETH vs. ERC-20).
- Users will not duplicate input data.
- Inputs will not reference non-existent IDs.
- Inputs will be within specified ranges.
- Invalid signatures will not be provided.
- Hashes will match expected input formats.
- Users will not send mismatched parameter types.
2. Call Order-Related Assumptions
- Functions will always be called in the expected order.
- Users will not skip initialization steps.
- Deposits will always occur before withdrawals.
- Staking will always precede claiming rewards.
- Users will follow the required sequence for approvals and transfers.
- State-dependent calls will occur in valid states only.
- Users will not bypass intermediate validation steps.
- Admins will set critical parameters before system activation.
- Initialization will occur exactly once.
- Reinitialization functions will not be called maliciously.
3. External Call-Related Assumptions
- External contracts will not revert unexpectedly.
- Tokens will implement the full ERC-20 or ERC-721 standard.
- Fallback functions will not be exploited.
- Oracles will provide timely and accurate data.
- Token transfers will not trigger reentrancy.
- External data feeds will not be manipulated.
- Delegated calls will not execute malicious logic.
- Proxy contracts will point to valid implementations.
- External dependencies will not be updated unexpectedly.
- Malicious tokens will not cause denial of service.
4. Permission and Role-Related Assumptions
- Only authorized users will call sensitive functions.
- Admin roles will not be misassigned.
- No unauthorized user will gain access to restricted functionality.
- Privileged roles will not be abused.
- Ownership transfers will occur securely.
- Contract migration will preserve permissions correctly.
- Critical configuration functions will only be accessible to the owner.
- Time-locked roles will wait for the correct duration.
- Multisig wallets will function as expected.
- No privileged roles will perform unexpected actions.
5. Economic/Game-Theoretic Assumptions
- Users will not manipulate rewards for personal gain.
- Users will not collude to break system fairness.
- Flash loans will not exploit economic logic.
- Users will not manipulate auction prices unfairly.
- Liquidity providers will not abuse fee structures.
- Validators will not act maliciously to gain rewards.
- Users will not game staking mechanisms.
- Governance participants will act in good faith.
- Incentives will align with intended behaviors.
- Arbitrage opportunities will not cause systemic loss.
6. Time and Sequence-Related Assumptions
- Block timestamps will not be manipulated.
- Functions will be called within expected time windows.
- Timelocks will not be bypassed or miscalculated.
- Rewards will be claimed in the correct time frame.
- Events will occur in their expected order.
- Blocks will be mined at expected intervals.
- Expiry dates will be enforced correctly.
- Users will not exploit outdated state between calls.
- Epoch changes will trigger appropriate state updates.
- State-dependent functions will execute atomically.
7. Math and Precision-Related Assumptions
- Division operations will not cause rounding errors.
- Decimal precision will match token standards.
- Arithmetic operations will not cause overflow.
- Subtractions will not result in negative balances.
- Reward calculations will distribute funds accurately.
- Fees will not reduce balances below zero.
- Multiplication will not cause unintended scaling.
- Token amounts will remain within expected precision.
- Iterative calculations will not lose precision over time.
- Conversion rates will be consistently applied.
8. State and Storage-Related Assumptions
- State variables will always initialize correctly.
- Storage reads will reflect the latest state.
- State transitions will occur atomically.
- No state updates will be partially applied.
- Iterative processes will complete in one call.
- Reserved storage slots will not be overwritten.
- Contracts will not reference stale or uninitialized variables.
- Mapping keys will not produce collisions.
- System state will reflect accurate user balances.
- Migration processes will transfer state correctly.
9. System and Deployment Assumptions
- Contract addresses will not collide.
- Proxy deployments will use valid initialization.
- Libraries will not introduce unexpected behavior.
- Immutable variables will not be overwritten.
- Contract deployment order will follow dependencies.
- Upgrades will preserve existing state and logic.
- Deployed bytecode will match verified source code.
- Deployment gas costs will not exceed block limits.
- Multi-contract systems will synchronize correctly.
- Contracts will not rely on deprecated or unsupported opcodes.
This post is licensed under CC BY 4.0 by the author.