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

Lack of upperbound on iterated array rewardTokens in AuraLocker #265

Open
code423n4 opened this issue May 24, 2022 · 1 comment
Open

Lack of upperbound on iterated array rewardTokens in AuraLocker #265

code423n4 opened this issue May 24, 2022 · 1 comment
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-05-aura/blob/4989a2077546a5394e3650bf3c224669a0f7e690/contracts/AuraLocker.sol#L195-L202

Vulnerability details

Impact

There is no upper bound on the size of the array rewardTokens in AuraLocker.

Since this array is iterated in multiple locations such as updateReward(), getReward(), claimableRewards() it is possible to end up in a state where there are too many reward tokens such that the contract cannot be iterated over them within the block gas limit.

The impact is that no rewards will be able to be withdrawn from the contract since the array rewardTokens is required to be iterated over in order to withdraw rewards.

This issue is rated Medium rather than High since addReward() which increases the size of this array is controlled via the DAO.

Proof of Concept

There are no restrictions on the number of tokens that can be pushed to rewardTokens in addReward().

    function addReward(address _rewardsToken, address _distributor) external onlyOwner {
        require(rewardData[_rewardsToken].lastUpdateTime == 0, "Reward already exists");
        require(_rewardsToken != address(stakingToken), "Cannot add StakingToken as reward");
        rewardTokens.push(_rewardsToken);
        rewardData[_rewardsToken].lastUpdateTime = uint32(block.timestamp);
        rewardData[_rewardsToken].periodFinish = uint32(block.timestamp);
        rewardDistributors[_rewardsToken][_distributor] = true;
    }

Recommended Mitigation Steps

Consider having a configurable upper bound that is set by the DAO to prevent accidental increase in the number of rewards tokens to a point where they cannot be iterated in the block gas limit.

@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 May 24, 2022
code423n4 added a commit that referenced this issue May 24, 2022
@0xMaharishi 0xMaharishi added the duplicate This issue or pull request already exists label May 28, 2022
@dmvt dmvt added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Jun 24, 2022
@dmvt
Copy link
Collaborator

dmvt commented Jun 24, 2022

Downgrading to QA. While this is a valid report, the ability to add reward tokens is tightly controlled making this highly unlikely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Projects
None yet
Development

No branches or pull requests

3 participants