The approve function in the CapitalPool contract can be called by anyone, not just the intended TokenManager contract. This unrestricted access could lead to core functionality failures and potential malicious exploitation.
The root cause of the vulnerability is that the approve function lacks a proper access control mechanism, allowing any external account to call it.
Found in src/core/CapitalPool.sol at Line 24
@>: dev noted that
"only can be called by token manager"butapprovecan actually be called by anyone
Let us walk through the issue with the following scenario:
Alice, who is a legitimate user of the TokenManager, triggers a token transfer that requires approval from the CapitalPool.
Bob, a malicious actor, identifies this and frontruns Alice's transaction by calling the approve function with a malicious tokenAddr.
As a result, Bob's malicious contract gets approved to transfer tokens from the CapitalPool, leading to potential undefined behavior, or worse, he can DOS a transfer of tokens like USDT, which has strict approval rules requiring existing allowances to be zero before setting a new allowance.
@>: USDT requires user's
allowedbalance to be 0 before proceeds to update the allowance. By frontruning the permissionlessCapitalPool:approve, it's posible for BOB to DOS Alice's transaction.
This vulnerability is significant as aside from breaking Dev's intended core functionality, malicious actor can also DOS a token transfer process, especially with tokens like USDT that have specific allowance requirements.
Manual Review
Add a check to ensure that only the TokenManager contract can call the approve function:
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.