50490 sc high user loses reward tokens during validator user relationship clearing
Description
Brief/Intro
Vulnerability Details
function adminClearValidatorRecord(
address user,
uint16 slashedValidatorId
) external onlyRole(PlumeRoles.ADMIN_ROLE) {
PlumeStakingStorage.Layout storage $ = PlumeStakingStorage.layout();
if (user == address(0)) {
revert ZeroAddress("user");
}
if (!$.validatorExists[slashedValidatorId]) {
revert ValidatorDoesNotExist(slashedValidatorId);
}
if (!$.validators[slashedValidatorId].slashed) {
revert ValidatorNotSlashed(slashedValidatorId);
}
uint256 userActiveStakeToClear = $.userValidatorStakes[user][slashedValidatorId].staked;
PlumeStakingStorage.CooldownEntry storage cooldownEntry = $.userValidatorCooldowns[user][slashedValidatorId];
uint256 userCooledAmountToClear = cooldownEntry.amount;
bool recordChanged = false;
if (userActiveStakeToClear > 0) {
@> $.userValidatorStakes[user][slashedValidatorId].staked = 0;
// Decrement user's global stake
if ($.stakeInfo[user].staked >= userActiveStakeToClear) {
$.stakeInfo[user].staked -= userActiveStakeToClear;
} else {
$.stakeInfo[user].staked = 0; // Should not happen if state is consistent
}
emit AdminClearedSlashedStake(user, slashedValidatorId, userActiveStakeToClear);
recordChanged = true;
}
...
if ($.userHasStakedWithValidator[user][slashedValidatorId] || recordChanged) {
PlumeValidatorLogic.removeStakerFromValidator($, user, slashedValidatorId);
}
}Impact Details
References
Proof of Concept
Previous51814 sc insight checkpoint cumulativeindex returned in the getrewardratecheckpoint function will be zeroNext50022 sc low missing admin pause unpause functions in tellerwithmultiassetsupportpredicateproxy contract
Was this helpful?