Popcorn contest - supernova'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: 78/169

Findings: 2

Award: $90.41

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

2.3058 USDC - $2.31

Labels

bug
3 (High Risk)
disagree with severity
partial-50
sponsor confirmed
duplicate-402

External Links

Lines of code

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

Vulnerability details

Impact

claimRewards function is prone to ERC777 Reentrancy . Checks -Effects-Interaction Pattern is not followed properly which leads to user being able to claim rewards token till the full contract is empty. At line 186

accruedRewards[user][_rewardTokens[i]] = 0;

The mapping is updated at the end of the function execution, which leads to reentrancy in the below code

if (escrowInfo.escrowPercentage > 0) { _lockToken(user, _rewardTokens[i], rewardAmount, escrowInfo); emit RewardsClaimed(user, _rewardTokens[i], rewardAmount, true); } else { _rewardTokens[i].transfer(user, rewardAmount); emit RewardsClaimed(user, _rewardTokens[i], rewardAmount, false); }

Proof of Concept

Tools Used

Manual

function claimRewards(address user, IERC20[] memory _rewardTokens) external accrueRewards(msg.sender, user) { for (uint8 i; i < _rewardTokens.length; i++) { uint256 rewardAmount = accruedRewards[user][_rewardTokens[i]]; + accruedRewards[user][_rewardTokens[i]] = 0; if (rewardAmount == 0) revert ZeroRewards(_rewardTokens[i]); EscrowInfo memory escrowInfo = escrowInfos[_rewardTokens[i]]; if (escrowInfo.escrowPercentage > 0) { _lockToken(user, _rewardTokens[i], rewardAmount, escrowInfo); emit RewardsClaimed(user, _rewardTokens[i], rewardAmount, true); } else { _rewardTokens[i].transfer(user, rewardAmount); emit RewardsClaimed(user, _rewardTokens[i], rewardAmount, false); } - accruedRewards[user][_rewardTokens[i]] = 0; } }

#0 - c4-judge

2023-02-16T07:38:37Z

dmvt marked the issue as duplicate of #54

#1 - c4-sponsor

2023-02-18T12:10:50Z

RedVeil marked the issue as sponsor confirmed

#2 - c4-sponsor

2023-02-18T12:11:50Z

RedVeil marked the issue as disagree with severity

#3 - c4-judge

2023-02-23T00:52:29Z

dmvt marked the issue as partial-50

Findings Information

🌟 Selected for report: aashar

Also found by: 0xmuxyz, 7siech, Aymen0909, hashminer0725, rbserver, supernova

Labels

bug
2 (Med Risk)
satisfactory
sponsor confirmed
duplicate-396

Awards

88.0962 USDC - $88.10

External Links

Lines of code

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L88

Vulnerability details

Impact

According to the Vault contract https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L523

Fees can never be 1e18 i.e 100%. For this the required checks are present that prevent the following action by the vault's owner .

Proof of Concept

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L525-L537

Although owner cannot set Fee to 100% using the above function , but there is no restriction on the owner to set fee = 1e18(i.e 100%) in the initialize function .

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol#L88

I consider this as a medium severity as this breaks the invariant that Fees cannot be 100% in any case , which is false.

Tools Used

In Vault.sol initialize function add the following

+        if (
+            fees_.deposit >= 1e18 ||
+            fees_.withdrawal >= 1e18 ||
+            fees_.management >= 1e18 ||
+            fees_.performance >= 1e18
+.         )

#0 - c4-sponsor

2023-02-17T07:48:16Z

RedVeil marked the issue as sponsor confirmed

#1 - c4-judge

2023-02-23T16:23:39Z

dmvt marked issue #396 as primary and marked this issue as a duplicate of 396

#2 - c4-judge

2023-02-23T22:28:00Z

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