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: 96/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
The owner of the WardenPledge.sol
smart contract can steal all the reward tokens from the contract and break the internal accounting. With the recoverERC20
function, the owner can transfer to him/herself the whole balance of the token.
The check at L654
(if(minAmountRewardToken[token] != 0) revert Errors.CannotRecoverToken();
) can be bypassed by first calling the removeRewardToken
function and setting the if(minAmountRewardToken[token]
to zero.
This will also break the internal accounting, as multiple functions of the smart contract, like closePledge
and retrievePledgeRewards
will break.
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; }
removeRewardToken
function with the address of the tokenA and sets the value of the minAmountRewardToken[token]
mapping to zerorecoverERC20
function with the address of the tokenA and transfers to herself the whole balance of the tokenAManual code review
It is recommended to delete the removeRewardToken
function or to create a mapping that tracks the balance of the reward token that is transferred to the smart contract, and then let the owner to only call the recoverERC20
function with the difference amount: uint256 amount = IERC20(token).balanceOf(address(this)) - amountOfToken[token];
#0 - Kogaroshi
2022-10-31T00:42:52Z
Duplicate of #17
#1 - c4-judge
2022-11-10T07:07:53Z
kirk-baird marked the issue as not a duplicate
#2 - c4-judge
2022-11-10T07:07:59Z
kirk-baird marked the issue as duplicate
#3 - c4-judge
2022-11-10T21:18:10Z
kirk-baird marked the issue as satisfactory
#4 - c4-judge
2022-11-10T21:18:15Z
kirk-baird marked the issue as not a duplicate
#5 - c4-judge
2022-11-10T21:18:21Z
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