Skip to content

Insecure Exact Balance Check

Description

Testing the balance of an account as a basis for some action has risks associated with unexpected receipt of ether or another token, including tokens deliberately transferred to cause such tests to fail, as an MEV attack.

Examples

Insecure Code

solidity
if (balanceOf(account) == 10) { ... }

Secure Code

solidity
if (balanceOf(account) >= 5 && balanceOf(account) <= 15) { ... }

Remediation

Use a secure comparison method, such as checking for a range of values instead of an exact balance, to prevent potential MEV attacks.

Rule Details

FieldValue
IDCODE-0657
CategoryCrypto
SeverityMEDIUM
CWECWE-667
ConfidenceLOW
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
TagsMEV attack, exact balance check
OWASPN/A

References