TempleGold

TempleDAO
Foundry
25,000 USDC
View results
Submission Details
Severity: high
Invalid

lack of Index Validation

Summary

The withdraw and withdrawAll functions do not validate the index parameter before accessing the stake information. If the index is invalid (i.e., it does not correspond to any stake), this can lead to undefined behaviour, potential reverts, or unintended actions by the contract.

Impact

  • Undefined Behavior: Accessing an invalid index can result in unpredictable contract behaviour.

  • Potential Reverts: The contract may revert if the index is out of bounds, causing transaction failure.

  • Security Risks: Malicious users might exploit this to disrupt contract operations or cause a denial of service.

function withdraw(uint256 amount, uint256 index, bool claim) external override {
StakeInfo storage _stakeInfo = _stakeInfos[msg.sender][index]; // Potentially invalid index
_withdrawFor(_stakeInfo, msg.sender, msg.sender, index, amount, claim, msg.sender);
}
function withdrawAll(uint256 stakeIndex, bool claim) external override {
StakeInfo storage _stakeInfo = _stakeInfos[msg.sender][stakeIndex]; // Potentially invalid index
_withdrawFor(_stakeInfo, msg.sender, msg.sender, stakeIndex, _stakeInfo.amount, claim, msg.sender);
}

Tools Used

Manual Review

Recommendations

Validate Index: Ensure the index is within the valid range before accessing the stake information. Add a check to verify that the index exists in the user's stake list.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.