Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Balance Check Missing in withdraw Function of shelf Contracts Leading to Potential Arithmetic Underflow

Summary

he withdraw function in various shelf contracts does not verify the balance before performing subtraction operations. This can lead to arithmetic underflow errors when attempting to withdraw more funds than are available. This affects all withdraw operations MoneyShelf, MoneyVault,WeaponShelf and by extension the withdraw function in laundrette (laundrette::takeGuns and laundrette::withdrawMoney)

Vulnerability Details

The function withdraw in the shelf contracts does not verify the balance before performing subtraction operations. This can result in arithmetic underflow errors when attempting to withdraw more funds than are available.

Impact

Failing to check balances before subtraction can cause arithmetic underflow errors. This may allow users to withdraw more funds than they actually have, compromising the integrity and security of the contract. The vulnerability could lead to loss of funds or contract malfunction, affecting all users interacting with the withdrawal function## Tools Used
Manual review

Recommendations

To mitigate this issue, it is essential to check the balance before performing subtraction operations. This can be achieved by adding a require statement to ensure that the balance is sufficient for the withdrawal.

function withdraw(address account, uint256 amount) public permissioned {
+ require(bank[account] >= amount, "Insufficient balance");
bank[account] -= amount;
}
Updates

Lead Judging Commences

n0kto Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.