You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
activateOperator does not update the OperatorUtilizationHeap
Summary
The activateOperator() function activates an inactive operator by increasing the activeOperatorCount by one and setting the operator status to active. This implementation is wrong as the OperatorUtilizationHeap does not include the inactive operator id after removing it.
Vulnerability Detail
The following example illustrates the issue (see also Code Snippet paragraph). The OperatorUtilizationHeap has 5 elements and the raw dump of the heap is as follows:
0: 0,01: 1,22: 5,103: 3,6,
4: 2,35:,4,8
Let's assume that the operator with index 3 is deactivated. The removal of an operator from the heap happens in setOperatorValidatorCap() by utilizationHeap.removeByID(operatorId) on line 303 in OperatorRegistryV1Admin. After the removal the heap only contains 4 elements. The raw dump of the heap shows that slot 3 has been overwritten with operator index 4 (see in the following code paragraph). So the heap now contains two elements for operator id 4. This is correct because removing the element also decreased the size of the heap by one. The activateOperator() increases the size of the heap by one without adding the element to the heap again. For the implementation, this means that the operator index with index 4 occurs twice on the heap, but the operator with index 3 that should be activated is missing.
0: 0,01: 1,22: 5,103: 4,84: 2,35: 4,8
Impact
Operator indexes on the heap must be unique, and they can not occur multiple times because this could cause severe accounting issues across the contract system.
sherlock-admin2
changed the title
Puny Sage Mockingbird - activateOperator does not update the OperatorUtilizationHeap
thec00n - activateOperator does not update the OperatorUtilizationHeapMar 26, 2024
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
thec00n
high
activateOperator
does not update theOperatorUtilizationHeap
Summary
The
activateOperator()
function activates an inactive operator by increasing theactiveOperatorCount
by one and setting the operator status to active. This implementation is wrong as theOperatorUtilizationHeap
does not include the inactive operator id after removing it.Vulnerability Detail
The following example illustrates the issue (see also Code Snippet paragraph). The
OperatorUtilizationHeap
has 5 elements and the raw dump of the heap is as follows:Let's assume that the operator with index 3 is deactivated. The removal of an operator from the heap happens in
setOperatorValidatorCap()
byutilizationHeap.removeByID(operatorId)
on line 303 in OperatorRegistryV1Admin. After the removal the heap only contains 4 elements. The raw dump of the heap shows that slot 3 has been overwritten with operator index 4 (see in the following code paragraph). So the heap now contains two elements for operator id 4. This is correct because removing the element also decreased the size of the heap by one. TheactivateOperator()
increases the size of the heap by one without adding the element to the heap again. For the implementation, this means that the operator index with index 4 occurs twice on the heap, but the operator with index 3 that should be activated is missing.Impact
Operator indexes on the heap must be unique, and they can not occur multiple times because this could cause severe accounting issues across the contract system.
Code Snippet
Tool used
Manual Review
Recommendation
Use
OperatorRegistryV1Admin.insert()
function to add the inactive operator to the heap again.Duplicate of #193
The text was updated successfully, but these errors were encountered: