Popcorn contest - Krace's results

A multi-chain regenerative yield-optimizing protocol.

General Information

Platform: Code4rena

Start Date: 31/01/2023

Pot Size: $90,500 USDC

Total HM: 47

Participants: 169

Period: 7 days

Judge: LSDan

Total Solo HM: 9

Id: 211

League: ETH

Popcorn

Findings Distribution

Researcher Performance

Rank: 165/169

Findings: 1

Award: $4.61

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

4.6115 USDC - $4.61

Labels

bug
3 (High Risk)
satisfactory
sponsor confirmed
duplicate-402

External Links

Lines of code

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/utils/MultiRewardStaking.sol#L172

Vulnerability details

Impact

In claimRewards, the rewardAmount is cached and then a _rewardTokens[i].transfer is triggered which can lead to exploits if the _rewardTokens[i] is a token that gives control to the sender, like ERC777 tokens.

Proof of Concept

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/utils/MultiRewardStaking.sol#L172

Initial state: msg.sender has some ERC777 tokens in accruedRewards[user][_rewardTokens[i]]

  1. The msg.sender call claimRewards with his own address and ERC777 token

  2. rewardAmount is not equal to zero and escrowInfo.escrowPercentage > 0 is false

  3. _rewardTokens[i].transfer(user, rewardAmount); will transfer tokens to the sender and gives control to the sender

  4. The sender can call claimRewards again with the same args in step 1, until the contract has no balance.

Tools Used

Update the accruedRewards[user][_rewardTokens[i]] before transfer.

#0 - c4-judge

2023-02-16T07:39:53Z

dmvt marked the issue as duplicate of #54

#1 - c4-sponsor

2023-02-18T12:11:10Z

RedVeil marked the issue as sponsor confirmed

#2 - c4-judge

2023-02-23T00:49:11Z

dmvt marked the issue as partial-50

#3 - c4-judge

2023-03-01T00:38:11Z

dmvt marked the issue as full credit

#4 - c4-judge

2023-03-01T00:38:16Z

dmvt marked the issue as satisfactory

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