if the validator status is changed an Overlap might happen in which it will try to subtract twice from the validator status
Vulnerability Details
#. requestDelegationExit (Line 568) When a user calls requestDelegationExit, if the validator's status is ACTIVE or PENDING, the _updatePeriodEffectiveStake function is called to decrease the effective stake:
Condition: Validator status is ACTIVE or PENDING
.Action: Decreases the effective stake immediately upon exit request.
This is the first decrease. #2. _delegate (Line 402, triggered by delegation/redelegation) The _delegate function handles new delegations or transfers. It includes logic to handle delegations whose previous delgator has exited
.Condition: The previously delegated validator's status is VALIDATOR_STATUS_EXITED. and the previously delegator status is exited
Action: Decreases the effective stake associated with the old delegation. -This is the second decrease. #The Overlap Scenario The double decrease occurs in this sequence:A user requests an exit (requestDelegationExit) while the validator is ACTIVE. First Decrease (Line 568) happens. the validator's status remains relevant. The validator updates status to VALIDATOR_STATUS_EXITED (due to external protocol rules).The user calls _delegate (to delegate to a new validator .Since the previous delgator status is now EXITED,
and the validator status is VALIDATOR_STATUS_EXITED the logic at Line 402 is triggered. Second Decrease (Line 402) happens for the same original stake amount. Result: The effective stake for that delegation amount is decreased twice—once when the exit was requested, and a second time when the validator became exited and a subsequent delegation function was called.
Impact Details
loss of the stake for the validator
Permanent freezing of funds
References
Add any relevant links to documentation or code
Proof of Concept
Proof of Concept
add this code in the test folder Delegation.test and what this code do is first delegator then it will see how much the effective stake of the validator is then call requestDelegationExit withdrawal delegator then change the validator status in to VALIDATOR_STATUS_EXITED then call the delegator function after that it will see how much of stake was decreased from the previous validator