Paladin - Warden Pledges contest - Picodes'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: 9/96

Findings: 4

Award: $795.60

QA:
grade-b
Gas:
grade-b

🌟 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

Vulnerability details

Impact

In recoverERC20, the code is designed to make it looks like the owner cannot withdraw pledge rewards from the contract, although it is doable.

Proof of Concept

To bypass the requirement minAmountRewardToken[token] == 0 the owner can just call removeRewardToken and then call recoverERC20.

Out of clarity for users, either:

  • clearly indicate that the owner can withdraw funds from the contract
  • or store the amounts of each token that cannot be recovered by the owner to really enforce that the owner cannot withdraw pledge rewards

#0 - Kogaroshi

2022-10-30T23:50:50Z

Duplicate of #17

#1 - c4-judge

2022-11-10T07:12:01Z

kirk-baird marked the issue as not a duplicate

#2 - c4-judge

2022-11-10T07:12:25Z

kirk-baird marked the issue as duplicate

#3 - c4-judge

2022-11-10T21:22:12Z

kirk-baird marked the issue as satisfactory

#4 - c4-judge

2022-11-10T21:22:16Z

kirk-baird marked the issue as not a duplicate

#5 - c4-judge

2022-11-10T21:22:23Z

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

Findings Information

🌟 Selected for report: Chom

Also found by: Jeiwan, KingNFT, Picodes

Labels

bug
2 (Med Risk)
satisfactory
duplicate-91

Awards

754.535 USDC - $754.53

External Links

Lines of code

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

Vulnerability details

Impact

votingEscrow.balance decreases over time, so votesDifference is not accurate anymore when a pledge is extended or increased. This does not lead to criticial errors but may prevent a pledge to reach its targetVotes.

Proof of Concept

Pedge.votesDifference is initialized with: vars.votesDifference = targetVotes - votingEscrow.balanceOf(receiver);

But the votingEscrow.balance decreases over time, so the votesDifference is not accurate when extendPledge or increasePledgeRewardPerVote is called, leading to fewer tokens than necessary to reach targetVotes being transfered;

Do not store votesDifference but fetch it again in extendPledge and increasePledgeRewardPerVote;

#0 - Kogaroshi

2022-10-30T23:52:49Z

Duplicate of #91

#1 - c4-judge

2022-11-10T22:50:26Z

kirk-baird marked the issue as satisfactory

#2 - c4-judge

2022-11-10T22:50:30Z

kirk-baird marked the issue as not a duplicate

#3 - c4-judge

2022-11-10T22:50:46Z

kirk-baird marked the issue as duplicate of #91

#4 - kirk-baird

2022-11-10T22:52:46Z

This bug references voting decay in relation to extendPledge() and increasePledgeRewardPerVote() but also how target votes may not be reached in the usual case.

[NC-1] Incorrect formatting:

https://github.com/code-423n4/2022-10-paladin/blob/d6d0c0e57ad80f15e9691086c9c7270d4ccfe0e6/contracts/WardenPledge.sol#L28 struct Pledge{ -> struct Pledge {

[NC-2] Redundant info

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

(in BPS) and // bps are the same info. No need to write it twice.

[NC-3] Invalid comments

All comments related to events are incorrect (Event emitted when xx)

Example here

[NC-4] Typo

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

minmum -> minimum

[NC-5] Typo

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

tof -> of

[NC-6] Typo

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

ot -> to

[NC-7] Typo

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

Maximum taget of votes to have (own balacne + delegation) for the receiver -> Maximum target of votes to have (own balance + delegation) for the receiver

#0 - c4-judge

2022-11-12T00:22:55Z

kirk-baird marked the issue as grade-b

[GAS-1] Pledge variables could be batched

In Pledge, targetVotes and rewardPerVote could safely be stored in uint128 to batch them and save a SLOAD in _pledge, extendPledge and increasePledgeRewardPerVote. Considering 18 decimals token there is no risk of overflow.

[GAS-2] It can be cheaper to avoid loading pledgeParams in memory

In _pledge, pledgeParams is loaded in memory but votesDifference is not used, hence is loaded for nothing and a SLOAD could be saved.

#0 - c4-judge

2022-11-12T00:22:28Z

kirk-baird marked the issue as grade-b

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