59615 sc high off by one error in period boundary check allows theft of unclaimed yield after delegation exit
Description
Brief / Intro
Vulnerability Details
function _claimableDelegationPeriods(
StargateStorage storage $,
uint256 _tokenId
) private view returns (uint32, uint32) {
// ... code ...
uint32 currentValidatorPeriod = completedPeriods + 1;
uint32 nextClaimablePeriod = $.lastClaimedPeriod[_tokenId] + 1;
// BUG: Line ~812
if (
endPeriod != type(uint32).max &&
endPeriod < currentValidatorPeriod &&
endPeriod > nextClaimablePeriod // Should be >=
) {
return (nextClaimablePeriod, endPeriod);
}
// Falls through when endPeriod == nextClaimablePeriod
if (nextClaimablePeriod < currentValidatorPeriod) {
return (nextClaimablePeriod, completedPeriods); // Returns wrong upper bound
}
return (0, 0);
}Impact Details
References
Link to Proof of Concept
Proof of Concept
Expected Output
Suggested Fix
Previous59570 sc medium access control bypass in unstake leads to permanent freezing of fundsNext59657 sc high delegators lose first reward period when delegating to pending validators
Was this helpful?