Paladin - Warden Pledges contest - wagmi'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: 93/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#L654

Vulnerability details

Impact

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);
}

Proof of Concept

Consider the scenario

  1. Admin whitelisted USDT as reward token.
  2. Alice (creator) created a pledge and transfer 100k USDT to WardenPledge contract
  3. Admin can call removeRewardToken(...) and recoverERC20(...) to drain 100k USDT from contract.

Tools Used

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

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