28973 - [SC - Insight] Users CDPs can be removed unintentionally by CD...
Description
Bug Description
function batchRemove(bytes32[] memory _ids) external override {
_requireCallerIsCdpManager();
uint256 _len = _ids.length;
require(_len > 1, "SortedCdps: batchRemove() only apply to multiple cdpIds!");
bytes32 _firstPrev = data.nodes[_ids[0]].prevId;
bytes32 _lastNext = data.nodes[_ids[_len - 1]].nextId;
require(
_firstPrev != dummyId || _lastNext != dummyId,
"SortedCdps: batchRemove() leave ZERO node left!"
);
for (uint256 i = 0; i < _len; ++i) {
require(contains(_ids[i]), "SortedCdps: List does not contain the id");
}
// orphan nodes in between to save gas
if (_firstPrev != dummyId) {
data.nodes[_firstPrev].nextId = _lastNext;
} else {
data.head = _lastNext;
}
if (_lastNext != dummyId) {
data.nodes[_lastNext].prevId = _firstPrev;
} else {
data.tail = _firstPrev;
}
// delete node & owner storages to get gas refund
for (uint i = 0; i < _len; ++i) {
delete data.nodes[_ids[i]];
emit NodeRemoved(_ids[i]);
}
size = size - _len;
}Impact
Recommendation
References
Proof Of Concept
Previous28967 - [SC - Insight] When fallback oracle is frozen fetchPrice can r...Next28980 - [SC - Insight] Ther is an invariant Check Failure in flashLoan...
Last updated
Was this helpful?