DittoETH

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

`flagShort()` does not check if `flaggerHint == 0`

Summary

flagShort() does not check if flaggerHint == 0, it may cause the malicious user call the flagShort() repeatly to prevent liquidation

Vulnerability Details

As we can see, flagShort() does not check if flaggerHint == 0, and then it will call the short.setFlagger(cusd, flaggerHint); to set the short.flaggerId is 0. So the flagShort() can be call repeatly to prevent liquidation

function flagShort(address asset, address shorter, uint8 id, uint16 flaggerHint)
external
isNotFrozen(asset)
nonReentrant
onlyValidShortRecord(asset, shorter, id)
{
if (msg.sender == shorter) revert Errors.CannotFlagSelf();
STypes.ShortRecord storage short = s.shortRecords[asset][shorter][id];
short.updateErcDebt(asset);
if (
short.getCollateralRatioSpotPrice(LibOracle.getSavedOrSpotOraclePrice(asset))
>= LibAsset.primaryLiquidationCR(asset)
) {
revert Errors.SufficientCollateral();
}
uint256 adjustedTimestamp = LibOrders.getOffsetTimeHours();
// check if already flagged
if (short.flaggerId != 0) {
uint256 timeDiff = adjustedTimestamp - short.updatedAt;
uint256 resetLiquidationTime = LibAsset.resetLiquidationTime(asset);
if (timeDiff <= resetLiquidationTime) {
revert Errors.MarginCallAlreadyFlagged();
}
}
short.setFlagger(cusd, flaggerHint);
emit Events.FlagShort(asset, shorter, id, msg.sender, adjustedTimestamp);
}

Impact

the malicious user call the flagShort() repeatly to prevent liquidation

Tools Used

manual

Recommendations

check if flaggerHint == 0

Updates

Lead Judging Commences

0xnevi Lead Judge
almost 2 years ago
0xnevi Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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