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

_getPromotion() doesn't revert on invalid _promotionId #2

Open
code423n4 opened this issue Dec 9, 2021 · 2 comments
Open

_getPromotion() doesn't revert on invalid _promotionId #2

code423n4 opened this issue Dec 9, 2021 · 2 comments
Assignees
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) 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

johnnycash

Vulnerability details

Impact

_getPromotion() doesn't revert if the specified _promotionId doesn't exist. It can lead to unexpected behaviors in callers of this function.

For instance, claimRewards will continue its execution and call _calculateRewardAmount() and eventually _promotion.token.safeTransfer() (probably with _rewardsAmount equal to 0).

Analysis

In contrary to the following comment:

@dev Will revert if the promotion does not exist.

_getPromotion() doesn't revert if the specified _promotionId doesn't exist, but return a Promotion structure with all fields set to 0.

Tools Used

Text editor.

Recommended Mitigation Steps

Fix suggestion:

    function _getPromotion(uint256 _promotionId) internal view returns (Promotion memory _promotion) {
        _promotion = _promotions[_promotionId];
        require(_promotion.creator != address(0), "TwabRewards/invalid-promotion");
        return _promotion;
    }
@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Dec 9, 2021
code423n4 added a commit that referenced this issue Dec 9, 2021
@PierrickGT PierrickGT added disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Dec 9, 2021
@PierrickGT
Copy link
Member

PierrickGT commented Dec 9, 2021

This is an issue we are going to fix but I think it should be of severity 1 (Low Risk) and not 2 (Med Risk).

@dmvt
Copy link
Collaborator

dmvt commented Jan 17, 2022

Agree with the sponsor regarding risk rating. This is a comment issue in an internal function.

1 — Low (L): vulns that have a risk of 1 are considered “Low” severity when assets are not at risk. Includes state handling, function incorrect as to spec, and issues with comments.

@dmvt dmvt added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jan 17, 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 disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) 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

3 participants