DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: medium
Invalid

Lack of ID Range Check in increaseCollateral, decreaseCollateral, and combineShorts Functions

Summary

Vulnerability Details

This vulnerability is due to the lack of range checks for the 'id' parameter in the 'increaseCollateral', 'decreaseCollateral', and 'combineShorts' functions. The 'id' parameter is used to index into the 'shortRecords' mapping, but there are no checks to ensure that the 'id' is within a valid range. This could potentially allow an attacker to manipulate or access arbitrary data in the 'shortRecords' mapping by providing an 'id' that is outside the expected range.

Impact

This could lead to unexpected behavior or potential loss of funds

Tools Used

Recommendations

To resolve this issue, you should add a function that checks if the provided ID is within the acceptable range. This function should be called within the increaseCollateral, decreaseCollateral, and combineShorts functions to validate the ID before any other operations are performed. Here is an example of how you could implement this:

function isValidId(uint8 id) internal pure returns (bool) {
uint8 maxId = 255; // replace with your maximum ID
return id <= maxId;
}
// Then in your functions, add this check:
function increaseCollateral(address asset, uint8 id, uint88 amount)
external
isNotFrozen(asset)
nonReentrant
onlyValidShortRecord(asset, msg.sender, id)
{
require(isValidId(id), "Invalid ID");
// rest of your code
}
// Do the same for decreaseCollateral and combineShorts!!

This will ensure that only valid IDs are processed, preventing potential errors or issues.

Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.