Skip to content

Latest commit

 

History

History
35 lines (28 loc) · 1.62 KB

044.md

File metadata and controls

35 lines (28 loc) · 1.62 KB

Furry Rusty Monkey

High

Users cannot withdraw their collateral in the Treasury.sol

Summary

Treasury::withdraw function contains a logic error in its require condition for verifying withdrawal eligibility. The condition incorrectly checks if the withdrawed flag is true, which blocks legitimate withdrawals for new deposits.

Vulnerability Details

Since the default value of withdrawed is false, any new deposit will initially have withdrawed = false.

require(depositDetails.withdrawed, "Already withdrawn");

The require statement above essentially requires the value to be true to proceed. If withdrawed is false (default), the statement fails, and the function reverts with the message "Already withdrawn" and blocking legitimate withdrawals.

But the expected behaviour is that withdrawals should only be allowed if the withdrawed flag is false, indicating that the deposit has not yet been withdrawn.

Impact

Users cannot withdraw their collateral from new deposits because the require condition fails for all deposits where withdrawed = false (default).

Code Snippet

https://github.com/sherlock-audit/2024-11-autonomint/blob/main/Blockchain/Blockchian/contracts/Core_logic/Treasury.sol#L239

Tools Used

Manual Review

Recommendation

  • Change the logic in the require statement to ensure withdrawals are allowed only when withdrawed is false:
require(!depositDetails.withdrawed, "Already withdrawn");

This ensures withdrawals are possible for new deposits.

  • Set the withdrawed flag to true after a successful withdrawal:
depositDetails.withdrawed = true;