Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

dhank - Able to update new startBlock greater then old startBlock #222

Closed
sherlock-admin2 opened this issue May 24, 2024 · 2 comments
Closed
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Disputed The sponsor disputed this issue's validity

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented May 24, 2024

dhank

medium

Able to update new startBlock greater then old startBlock

Summary

Not checking whether the new startBlock is greater than old startBLock while updating startBlock.Hence the wrong rewards are calculated when the old start Block > current block number

Vulnerability Detail

In the function

https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L272-L280

function setStartBlock(uint256 _startBlock) public onlyOwner {
        if (_startBlock == 0 || (endBlock != 0 && _startBlock >= endBlock)) {
            revert InvalidStartBlock();
        }
        if (getBlockNumber() > startBlock) {
            revert FarmingIsStarted();
        }
        startBlock = _startBlock;
    }

we dont have the condition to check whether the _startBlock > startBlock.
pool.lastRewardBlock still has the old value of startBLock.

Impact

pool.lastRewardBlock will store the incorrect value of old startBlock even though new startBlock has been initialised by owner.
As a result wrong rewards will get calculated.

Code Snippet

https://github.com/sherlock-audit/2024-05-sophon/blob/05059e53755f24ae9e3a3bb2996de15df0289a6c/farming-contracts/contracts/farm/SophonFarming.sol#L272-L280

Tool used

Manual Review

Recommendation

Duplicate of #108

@github-actions github-actions bot added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels May 28, 2024
@sherlock-admin4
Copy link
Contributor

1 comment(s) were left on this issue during the judging contest.

0xmystery commented:

valid because lastRewardBlock for each pool should indeed sync with the latest startBlock

@sherlock-admin3 sherlock-admin3 added the Sponsor Disputed The sponsor disputed this issue's validity label May 29, 2024
@mystery0x
Copy link
Collaborator

This report should be valid as it described scenario 1 of #108.

@sherlock-admin3 sherlock-admin3 changed the title Witty Amber Swan - Able to update new startBlock greater then old startBlock dhank - Able to update new startBlock greater then old startBlock Jun 1, 2024
@sherlock-admin3 sherlock-admin3 added the Reward A payout will be made for this issue label Jun 1, 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 Medium A valid Medium severity issue Reward A payout will be made for this issue Sponsor Disputed The sponsor disputed this issue's validity
Projects
None yet
Development

No branches or pull requests

4 participants