The TokenManager
fails to update internal accounting when processing withdrawals, permitting a caller to repeatedly double-spend their outstanding withdrawal balance.
Throughout the codebase there are multiple calls to TokenManager
's addTokenBalance(TokenBalanceType,address,address,uint256)
function, which is used to credit an account their deposited funds.
As an example, we can see that funds credited to an untrusted
_msgSender()
, when a referral bonus is accrued.This is to emphasize that it is trivial to create a token balance for an arbitrary (i.e. malicious third party) account address.
This token balance can be withdrawn from the TokenManager
via the withdraw(address,TokenBalanceType)
function, documented below for posterity:
Notice that when claimAbleAmount
is nonzero for the _msgSender()
(i.e. an attacker), they are permitted to withdraw the claimAbleAmount
from the contract, but this amount is never reduced.
This means an attacker may repeatedly invoke withdraw(address,TokenBalanceType)
to withdraw the same amount continuously until the point of contract insolvency.
All funds in the protocol can be stolen from the TokenManager
.
An attacker need initially instantiate a non-zero balance owed to their address in any unit of tokens currently held by the TokenManager
(exploiting free access to one of the many available invocations to addTokenBalance(TokenBalanceType,address,address,uint256)
) in order to repeatedly withdraw that amount until insolvency.
Manual Review
Ensure the withdrawn amount is zeroed out upon withdraw:
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.