The DepositsLinkedList::sumExpiredDeposits function will perform a subtraction insecurely between the current timestamp and the timestamp the deposit was performed in.
Impact:
The referenced subtraction should never underflow per the integration of DepositsLinkedList::insertEnd by ElasticVault::makeDeposit, however, we still advise the operation to be safely performed as an assertion-type security check.
Example:
function sumExpiredDeposits(List storage list, uint256 lock_duration) internal view returns (uint256 sum) {
uint current = list.head;
sum = 0;
while (current != NULL) {
if (lock_duration == 0 || ((block.timestamp - list.nodes[current].deposit.timestamp) > lock_duration)) {
sum = sum.add(list.nodes[current].deposit.amount);
}
current = list.nodes[current].next;
}
return sum;
}
Recommendation:
We advise the referenced operation to be performed safely as a security precaution, preventing potential timestamp inconsistencies from resulting in an overflow.
DLL-02M: Insecure Subtraction of Timestamps
Description:
The
DepositsLinkedList::sumExpiredDeposits
function will perform a subtraction insecurely between the current timestamp and the timestamp the deposit was performed in.Impact:
The referenced subtraction should never underflow per the integration of
DepositsLinkedList::insertEnd
byElasticVault::makeDeposit
, however, we still advise the operation to be safely performed as an assertion-type security check.Example:
Recommendation:
We advise the referenced operation to be performed safely as a security precaution, preventing potential timestamp inconsistencies from resulting in an overflow.