The withdraw function in TokenManager.sol is open to reentrancy attack, which will result in draining the pool.
The withdraw function defined as :
The function retrieves claimAbleAmount
for the msg.sender and deals with transfer of either native token or ERC20 withdrawals. However, In both cases , whether the token is native or Erc20 token, there is no update regarding userTokenBalanceMap
before executing the transfer, which allows the user to reenter the function and potentially drain the pool.
Imagine a sample attack scenario:
An attacker contract(Bob) has some native or Erc20 to claim and calls withdraw().
Bob's claimAbleAmount
is correctly retrieved, but his related balance in userTokenBalanceMap
is not updated.
Bob repeatedly can reenter the pool and withdraw the same amount until the pool has no funds.
The pool can be drained.
Manual Review
update the balance of msg.sender
before transfering the claimAbleAmount
. Add the following line of code
before cashing the address of capital Pool(capitalPoolAddr)
Valid critical severity finding, the lack of clearance of the `userTokenBalanceMap` mapping allows complete draining of the CapitalPool contract. Note: This would require the approval issues highlighted in other issues to be fixed first (i.e. wrong approval address within `_transfer` and lack of approvals within `_safe_transfer_from` during ERC20 withdrawals)
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.