Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

iamnmt - Incorrect order when setting top pool's weight will cause the LUM rewards to mint more than expected #175

Closed
sherlock-admin3 opened this issue Jul 15, 2024 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A High severity issue. Reward A payout will be made for this issue

Comments

@sherlock-admin3
Copy link
Contributor

sherlock-admin3 commented Jul 15, 2024

iamnmt

Medium

Incorrect order when setting top pool's weight will cause the LUM rewards to mint more than expected

Summary

Incorrect order when setting top pool's weight will cause the LUM rewards to mint more than expected.

Vulnerability Detail

From the code comments for Voter#setTopPoolIdsWithWeights

https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/Voter.sol#L250-L259

    /**
     * @dev Set farm pools with their weight;
     *
     * WARNING:
     * Caller is responsible to updateAll oldPids on masterChef before using this function
     * and also call updateAll for the new pids after.
     *
     * @param pids - list of pids
     * @param weights - list of weights
     */

the order when setting top pool's weight is

  1. MasterChef#updateAll(oldPids)
  2. Voter#setTopPoolIdsWithWeights(newPids)
  3. MasterChef#updateAll(newPids)

This order is also used in js/sync-farm.js and confirmed by the sponsor in a private thread.

Before (3), the newPids's rewarder.lastUpdateTimestamp is less than block.timestamp. By calling (3) the LUM rewards will be minted for newPids from rewarder.lastUpdateTimestamp to current block.timestamp, which cause the LUM rewards to mint more than expected.

Impact

Setting top pool's weight will cause LUM rewards minting more than expected.

Code Snippet

https://github.com/sherlock-audit/2024-06-magicsea/blob/42e799446595c542eff9519353d3becc50cdba63/magicsea-staking/src/Voter.sol#L250-L259

Tool used

Manual Review

Recommendation

Document the correct order to set top pool's weight

  1. MasterChef#updateAll(oldPids)
  2. MasterChef#updateAll(newPids)
  3. Voter#setTopPoolIdsWithWeights(newPids)

Duplicate of #107

@github-actions github-actions bot added duplicate High A High severity issue. labels Jul 21, 2024
@sherlock-admin4 sherlock-admin4 added the Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label label Jul 22, 2024
@sherlock-admin4 sherlock-admin4 changed the title Acidic Sable Loris - Incorrect order when setting top pool's weight will cause the LUM rewards to mint more than expected iamnmt - Incorrect order when setting top pool's weight will cause the LUM rewards to mint more than expected Jul 29, 2024
@sherlock-admin4 sherlock-admin4 added the Reward A payout will be made for this issue label Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A High severity issue. Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

2 participants