Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Missing Balance Check for User Shares Before Withdrawal

Summary

The initiateWithdrawal function lacks a check to ensure the user has sufficient shares before attempting the withdrawal. While the safeTransferFrom function reverts if the user’s balance is insufficient, the error is not clear, making it difficult for the user to understand the cause of failure.

Affected Line of Code

https://github.com/Cyfrin/2025-01-zaros-part-2/blob/main/src/market-making/branches/VaultRouterBranch.sol#L433-L460

Vulnerability Details

  • The function doesn’t verify the user's balance before transferring shares.

  • If the user doesn't have enough shares, the function silently reverts with no explanation, leading to a poor user experience.

  • Although the transaction won’t succeed without sufficient balance, the lack of clarity can cause confusion.

Impact

  • Severity: Medium

  • Likelihood: Medium

  • Impact: Medium

  • Business Impact: Users may become frustrated and lose trust due to unclear errors when attempting withdrawals.

  • Technical Impact: No security risk, but the lack of feedback affects system transparency and user experience.

Tools Used

Manual Review

Recommendations

  1. Add Balance Check:
    Before transferring shares, verify that the user has enough to withdraw. Example:

    uint256 userBalance = IERC20(vault.indexToken).balanceOf(msg.sender);
    if (userBalance < shares) {
    revert Errors.InsufficientBalance("shares", userBalance, shares);
    }
  2. Provide Clear Error Messaging:
    Use clear custom error messages to inform users why their withdrawal failed.

Updates

Lead Judging Commences

inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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