Paladin - Warden Pledges contest - 0xDecorativePineapple's results

A governance lending protocol transforming users voting power into a new money lego.

General Information

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

Paladin

Findings Distribution

Researcher Performance

Rank: 96/96

Findings: 1

Award: $9.91

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

9.9073 USDC - $9.91

Labels

bug
2 (Med Risk)
satisfactory
duplicate-68

External Links

Lines of code

https://github.com/code-423n4/2022-10-paladin/blob/d6d0c0e57ad80f15e9691086c9c7270d4ccfe0e6/contracts/WardenPledge.sol#L653-L661

Vulnerability details

Impact

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.

Proof of Concept

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; }
  • The owner calls to steal the whole balance of the tokenA
  • (S)he calls the removeRewardToken function with the address of the tokenA and sets the value of the minAmountRewardToken[token] mapping to zero
  • Then, (s)he calls the recoverERC20 function with the address of the tokenA and transfers to herself the whole balance of the tokenA

Tools Used

Manual 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

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter