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

jsmi - New top pool weights apply to the time before it has been set. #70

Closed
sherlock-admin3 opened this issue Jul 15, 2024 · 6 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Escalation Resolved This issue's escalations have been approved/rejected 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

jsmi

Medium

New top pool weights apply to the time before it has been set.

Summary

The top pool weights are used to calculate the farm rewards using accrued debt per share of pools.
Voter.sol#setTopPoolIdsWithWeights update the top pool weights but doesn't update the accrued debt per share of pools.
Therefore the newly set pool weights may apply to the time before it has been set.

Vulnerability Detail

Scenario:

  1. There are only two pools: pool1 with weight 20% and pool2 with weight 80% respectively.
  2. There are no activities changing the accrued debt per share of pools for some time for instance 1 hour.
  3. After that, the owner set the pools weight again: pool1 with 80% and pool2 with 20%.
  4. However the rewards of master chef are distributed to the pools for the very 1 hour such that 80% for pool1 and 20% for pool2.

Impact

New top pool weights apply to the time before it has been set.

Code Snippet

Tool used

Manual Review

Recommendation

Modify the Voter.sol#setTopPoolIdsWithWeights as follows.

    function setTopPoolIdsWithWeights(uint256[] calldata pids, uint256[] calldata weights) external {
        if (msg.sender != _operator) _checkOwner();

        uint256 length = pids.length;
        if (length != weights.length) revert IVoter__InvalidLength();

        uint256[] memory oldIds = _topPids.values();

+       _masterChef.updateAll(oldIds);

        ......
    }

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 Swift Sage Gerbil - New top pool weights apply to the time before it has been set. jsmi - New top pool weights apply to the time before it has been set. Jul 29, 2024
@sherlock-admin4 sherlock-admin4 added the Reward A payout will be made for this issue label Jul 29, 2024
@Oot2k
Copy link

Oot2k commented Aug 1, 2024

Escalate

I believe this issue lacks valid POC and description of impact, which makes this issue invalid.

@sherlock-admin3
Copy link
Contributor Author

Escalate

I believe this issue lacks valid POC and description of impact, which makes this issue invalid.

You've created a valid escalation!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

@sherlock-admin4 sherlock-admin4 added the Escalated This issue contains a pending escalation label Aug 1, 2024
@jsmi0703
Copy link

jsmi0703 commented Aug 2, 2024

@Oot2k

First, The following example scenario could replace the POC since it is fully clear to everyone.

Scenario:

  1. There are only two pools: pool1 with weight 20% and pool2 with weight 80% respectively.
  2. There are no activities changing the accrued debt per share of pools for some time for instance 1 hour.
  3. After that, the owner set the pools weight again: pool1 with 80% and pool2 with 20%.
  4. However the rewards of master chef are distributed to the pools for the very 1 hour such that 80% for pool1 and 20% for pool2.

Furthermore, I think that not all valid issues are required to have POC.
Of course it will be better to have coded POC like #107 and that's why this issue is a duplicate and not the original target issue.

Second, please compare impact of this issue:

New top pool weights apply to the time before it has been set.

with the impact of original issue #107:

Pools that have just made it into the top pools will have already accrued rewards for time intervals it wasn't in the top pools.

As you can see, they essentially stated the same impact about the new top pools (not old ones) for the past time.
Anyway, the conclusion on validity of this issue is up to the judge.

@WangSecurity
Copy link

Yep, I agree that not all issues require POCs, only the ones that fall under the POC requirements. Additionally, POC can be either coded or written, so here it's sufficient I believe.

I agree that the impact inside the Impact section is not very convincing, but the 4th step of the vulnerability path explains it well enough:

However the rewards of master chef are distributed to the pools for the very 1 hour such that 80% for pool1 and 20% for pool2

Hence, I believe it's sufficient duplicate, planning to reject the escalation and leave the issue as it is.

@WangSecurity
Copy link

WangSecurity commented Aug 6, 2024

Result:
High
Duplicate of #107

@sherlock-admin2
Copy link

sherlock-admin2 commented Aug 6, 2024

Escalations have been resolved successfully!

Escalation status:

@sherlock-admin3 sherlock-admin3 removed the Escalated This issue contains a pending escalation label Aug 6, 2024
@sherlock-admin4 sherlock-admin4 added the Escalation Resolved This issue's escalations have been approved/rejected label Aug 6, 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 Escalation Resolved This issue's escalations have been approved/rejected High A High severity issue. Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

6 participants