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

Irissme - Missing Range Check in removeStakingRewardsContract Function #43

Closed
sherlock-admin2 opened this issue Jan 15, 2024 · 4 comments
Assignees
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Jan 15, 2024

Irissme

medium

Missing Range Check in removeStakingRewardsContract Function

Summary

The removeStakingRewardsContract function in the StakingRewardsManager.sol file lacks a check to ensure that the provided index i is within the bounds of the stakingContracts array. This omission may lead to unexpected memory access issues.

Vulnerability Detail

The vulnerability lies in the removeStakingRewardsContract function, where the absence of a check on the index may result in accessing memory outside the valid range of the stakingContracts array.

Impact

This vulnerability could potentially lead to runtime errors, including but not limited to accessing unexpected memory locations, which may compromise the integrity and functionality of the contract.

Code Snippet

https://github.com/sherlock-audit/2024-01-telcoin/blob/main/telcoin-audit/contracts/telx/core/StakingRewardsManager.sol#L166-L179

Tool used

Manual Review

Recommendation

function removeStakingRewardsContract(uint256 i) external onlyRole(BUILDER_ROLE) {
    require(i < stakingContracts.length, "Invalid index");

    StakingRewards staking = stakingContracts[i];

    // Un-mark this staking contract as included in stakingContracts
    stakingExists[staking] = false;

    // Replace the removed staking contract with the last item in the stakingContracts array
    if (i != stakingContracts.length - 1) {
        stakingContracts[i] = stakingContracts[stakingContracts.length - 1];
    }

    // Pop the last staking contract off the array
    stakingContracts.pop();

    emit StakingRemoved(staking);
}
@amshirif amshirif self-assigned this Jan 16, 2024
@amshirif amshirif added Medium A valid Medium severity issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed labels Jan 16, 2024
@amshirif
Copy link

@github-actions github-actions bot added Has Duplicates A valid issue with 1+ other issues describing the same vulnerability Excluded Excluded by the judge without consulting the protocol or the senior and removed Medium A valid Medium severity issue labels Jan 19, 2024
@sherlock-admin sherlock-admin changed the title Virtual Midnight Ladybug - Missing Range Check in removeStakingRewardsContract Function Irissme - Missing Range Check in removeStakingRewardsContract Function Jan 29, 2024
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Jan 29, 2024
@nevillehuang
Copy link
Collaborator

Invalid, this would constitute admin input error not valid based on sherlock rules

@sherlock-admin
Copy link
Contributor

The protocol team fixed this issue in PR/commit https://github.com/telcoin/telcoin-audit/pull/35.

@sherlock-admin
Copy link
Contributor

The Lead Senior Watson signed-off on the fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Excluded Excluded by the judge without consulting the protocol or the senior Non-Reward This issue will not receive a payout Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

4 participants