Closed sherlock-admin2 closed 8 months ago
The protocol team fixed this issue in the following PRs/commits: https://github.com/rio-org/rio-sherlock-audit/pull/14
The protocol team fixed this issue in the following PRs/commits: rio-org/rio-sherlock-audit#14
Fixed Sets allocation to 0
The Lead Senior Watson signed off on the fix.
Aymen0909
medium
queueOperatorStrategyExit
doesn't decrease the operator shares allocationSummary
The
queueOperatorStrategyExit
function doesn't decrease the operator shares allocation when removing them, potentially causing issues with future allocations and heap organization when the operator is included again.Vulnerability Detail
The
queueOperatorStrategyExit
function is utilized to queue a complete exit from the specified strategy for a given operator. It's called when changing the operator cap to 0 usingsetOperatorStrategyCap
.In the
setOperatorStrategyCap
function, when the new cap is set to 0, the operator is removed from the heap, and if the operator had an allocation,queueOperatorStrategyExit
function is invoked:The
queueOperatorStrategyExit
function is responsible for calculating the shares to exit and queuing the withdrawal:As observed, the function doesn't decrease the operator allocation at all but queues the shares for withdrawal directly.Thus, even if the operator was removed and all their allocation was withdrawn, in the protocol's internal accounting, they still have an allocation.
This can lead to problems later on if that operator is added again (if their shares cap is increased again > 0), as major protocol functions like
allocateStrategyShares
ordeallocateStrategyShares
rely on the value ofoperatorDetails[operatorId].shareDetails[strategy].allocation
. However, this value is not correct as it still indicates the old operator allocation, potentially causing incorrect behavior of those protocol functions (unable to allocate or deallocate new shares) and a wrong ordering in the heap structure.Impact
The
queueOperatorStrategyExit
function doesn't decrease the operator shares allocation when removing them, potentially causing issues with future allocations and heap organization when the operator is included again.Code Snippet
https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/main/rio-sherlock-audit/contracts/utils/OperatorRegistryV1Admin.sol#L144-L165
https://github.com/sherlock-audit/2024-02-rio-network-core-protocol/blob/main/rio-sherlock-audit/contracts/utils/OperatorRegistryV1Admin.sol#L248-L255
Tool used
Manual Review
Recommendation
The
queueOperatorStrategyExit
function must reset the removed operator allocation:Duplicate of #10