Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in function setLockPeriods, multiplier can be set to lower than 100 #96

Open
code423n4 opened this issue Jan 5, 2022 · 3 comments
Open
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")

Comments

@code423n4
Copy link
Contributor

Handle

Tomio

Vulnerability details

Impact

in function setLockPeriods multiplier can be set to lower than 100 which will break the calculation when dividing the multiplier in function lock https://github.com/XDeFi-tech/xdefi-distribution/blob/master/contracts/XDEFIDistribution.sol#L268. If the amount times bonus multiplier below 100 the units value will be 0, therefore the totalUnits won't be added but the positionOf[tokenId] bill be added.

Proof of Concept

https://github.com/XDeFi-tech/xdefi-distribution/blob/master/contracts/XDEFIDistribution.sol#L77
https://github.com/XDeFi-tech/xdefi-distribution/blob/master/contracts/XDEFIDistribution.sol#L268

Tools Used

Recommended Mitigation Steps

in function setLockPeriods need to be add

        uint256 count = durations_.length;

        for (uint256 i; i < count; ++i) {
            require(multipliers >= 100); //added
            uint256 duration = durations_[i];
            require(duration <= uint256(18250 days), "INVALID_DURATION");
            emit LockPeriodSet(duration, bonusMultiplierOf[duration] = multipliers[i]);
        }
    }
@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working labels Jan 5, 2022
code423n4 added a commit that referenced this issue Jan 5, 2022
@deluca-mike deluca-mike added the sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") label Jan 5, 2022
@deluca-mike
Copy link
Collaborator

Supporting less that 100 (i.e. less than 1x) was intended behaviour (i.e. 30-day lockup gets you normal rewards, and, say 0-day lockups gets you 0.5x rewards). However, there is a good catch that the resulting units from the calculation should be checked for 0 (instead of checking the amount_ argument for 0), since that's a better and more all-encompassing way to filter out amount that are too low (or zero) after taking the multiplier into account.

@deluca-mike
Copy link
Collaborator

deluca-mike commented Jan 14, 2022

As alluded to above, bonusMultiplier is allowed to be below 100, and amount_ is no longer validated, and instead, resulting units are validated.

@deluca-mike deluca-mike added the resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) label Jan 14, 2022
@Ivshti
Copy link
Member

Ivshti commented Jan 16, 2022

valid finding

@Ivshti Ivshti closed this as completed Jan 16, 2022
@CloudEllie CloudEllie reopened this Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Projects
None yet
Development

No branches or pull requests

4 participants