Platform: Code4rena
Start Date: 27/10/2022
Pot Size: $33,500 USDC
Total HM: 8
Participants: 96
Period: 3 days
Judge: kirk-baird
Total Solo HM: 1
Id: 176
League: ETH
Rank: 93/96
Findings: 1
Award: $9.91
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: ladboy233
Also found by: 0x52, 0xDecorativePineapple, 0xhunter, Aymen0909, Bnke0x0, Dravee, JTJabba, Jeiwan, Lambda, Nyx, Picodes, Trust, cccz, cryptonue, csanuragjain, dic0de, hansfriese, horsefacts, imare, minhtrng, pashov, peritoflores, rbserver, rvierdiiev, wagmi, yixxas
9.9073 USDC - $9.91
Function recoverERC20(...)
can be used to recover ERC20 tokens sent by mistake to the contract. It has a check that the ERC20 token is not whitelisted to prevent admin from withdrawing funds of users.
function recoverERC20(address token) external onlyOwner returns(bool) { if(minAmountRewardToken[token] != 0) revert Errors.CannotRecoverToken(); uint256 amount = IERC20(token).balanceOf(address(this)); if(amount == 0) revert Errors.NullValue(); IERC20(token).safeTransfer(owner(), amount); return true; }
However, admin can use another function removeRewardToken(...)
to remove token from whitelist then call recoverERC20(...)
. The function removeRewardToken(...)
does not have any check if there is any pledge with this token existing. This way, admin can rug pull and drain all funds of users in this contract.
function removeRewardToken(address token) external onlyOwner { if(token == address(0)) revert Errors.ZeroAddress(); if(minAmountRewardToken[token] == 0) revert Errors.NotAllowedToken(); minAmountRewardToken[token] = 0; emit RemoveRewardToken(token); }
Consider the scenario
removeRewardToken(...)
and recoverERC20(...)
to drain 100k USDT from contract.Manual Review
Consider adding the mechanism that only allowing admin remove reward token when there is no pledge with that token active.
For example, adding a mapping count[token]
that store number of active pledge with that token
.
#0 - Kogaroshi
2022-10-31T00:07:50Z
Duplicate of #17
#1 - c4-judge
2022-11-10T07:43:00Z
kirk-baird marked the issue as not a duplicate
#2 - c4-judge
2022-11-10T07:43:06Z
kirk-baird marked the issue as duplicate
#3 - c4-judge
2022-11-10T21:21:23Z
kirk-baird marked the issue as satisfactory
#4 - c4-judge
2022-11-10T21:21:29Z
kirk-baird marked the issue as not a duplicate
#5 - c4-judge
2022-11-10T21:21:37Z
kirk-baird marked the issue as duplicate of #17
#6 - c4-judge
2022-12-06T17:32:42Z
Simon-Busch marked the issue as duplicate of #68