The external function liquidateSecondary() can be called at any point of time by anyone with a huge array containing all duplicate elements and passed as the batches
param. The current structure of the code logic will continue looping till the end of the array, making the protocol service unavailable for other users.
Paste the following test inside the existing test/MarginCallSecondary.t.sol
and run via forge test --mt test_DoS_LiquidateSecondary -vv
:
2 variations:
In the above PoC, an attacker just picks up a valid short eligible for secondary liquidation and then calls liquidateSecondary()
using a huge duplicate array. In such a case, if and when control reaches L109 (this happens only after every element in the array has been looped through), the condition if (liquidateAmount == liquidateAmountLeft)
is not satisfied (as a short was genuinely liquidated) and the function exits gracefully.
There could be a variation where the attacker just picks up any existing short record which might not even be eligible for secondary liquidation, then creates a huge duplicate array with this id and finally calls liquidateSecondary()
. In this case, the code still loops through the whole array but if and when control reaches L109-L110, it reverts as no short got liquidated.
DoS attack makes the protocol service unavailable for other users.
Manual inspection and foundry.
Add the following constraint:
Developer can add a duplicate array element check too.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.