Current implementation throws if first operator is to be deleted, i.e. operators[0] == operator, and doesn't throw when operator is not found, i.e. there is no i such that operators[i] == operator. This way an expected logic of throwing whenever operator isn't found in current list and deleting the one found otherwise doesn't take place.
This way
operators[0] cannot be deleted
if there is no requested operator in the operators list, an array bounds check violation will happen
Handle
hyh
Vulnerability details
Impact
Current implementation throws if first operator is to be deleted, i.e.
operators[0] == operator
, and doesn't throw when operator is not found, i.e. there is noi
such thatoperators[i] == operator
. This way an expected logic of throwing whenever operator isn't found in current list and deleting the one found otherwise doesn't take place.This way
operators[0]
cannot be deletedoperators
list, an array bounds check violation will happenProof of Concept
NestedFactory.removeOperator code: https://github.com/code-423n4/2021-11-nested/blob/main/contracts/NestedFactory.sol#L79
Recommended Mitigation Steps
Function code needs to be updated, for example:
Now:
To be: