DeFiFoundry
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Wrong Encoding and Decoding of Accounts to Be Liquidated

Summary

In LiquidationKeepercontract, function checkUpkeepis used to construct array of accounts to be liquidated if there is any need to liquidation. The constructed array is passed to performUpkeep. The functions encodes wrong data and thus decoding in performUpKeepwill always fail.

Vulnerability Details

In function checkUpkeep, data encoding is done as follows. This data will be passed to performUpkeepfunction if upkeepNeededis true. If it's true, that means some accounts needs to be liquidated.

https://github.com/Cyfrin/2024-07-zaros/blob/d687fe96bb7ace8652778797052a38763fbcbb1b/src/external/chainlink/keepers/liquidation/LiquidationKeeper.sol#L85

bytes memory extraData = abi.encode(accountsToBeLiquidated, address(this));

In function performUpkeep, the data decoding is done as:

https://github.com/Cyfrin/2024-07-zaros/blob/d687fe96bb7ace8652778797052a38763fbcbb1b/src/external/chainlink/keepers/liquidation/LiquidationKeeper.sol#L101

uint128[] memory accountsToBeLiquidated = abi.decode(peformData, (uint128[]));

The above line will always revert because performDataalso contains addressin encoding. Due to this, performUpkeep will always revert and no accounts can be liquidated.

Impact

The protocol will be unable to liquidate accounts that have breached their maintenance margins, potentially leading to increased bad debt and financial loss in the system.

Tools Used

Manual review

Recommendations

There is no need to add address(this)in encoding in function checkUpkeep. It can be rewritten as follows:

bytes memory extraData = abi.encode(accountsToBeLiquidated);
Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Error is in decoding of `peformData`

Support

FAQs

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