Yield Witch v2 contest - kenzo's results

Fixed-rate borrowing and lending on Ethereum

General Information

Platform: Code4rena

Start Date: 14/07/2022

Pot Size: $25,000 USDC

Total HM: 2

Participants: 63

Period: 3 days

Judge: PierrickGT

Total Solo HM: 1

Id: 147

League: ETH

Yield

Findings Distribution

Researcher Performance

Rank: 35/63

Findings: 1

Award: $40.44

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2022-07-yield/blob/main/contracts/Witch.sol#L253

Vulnerability details

When an auction is going on, after it started, the vault might become overcollateralized again, due to liquidators buying early (and not receiving the full amount of collateral), or due to user supplying collateral to the vault.

In these cases (especially the first one), the vault might become overcollateralized, but the auction would be still be going on and bids allowed to be placed.

The only way to cancel an auction is either using the external cancel function or by paying all of the debt.

Impact

More collateral would be liquidated than needed to keep the vault's collateralization ratio.

I am not sure if this is intended behavior. But seems like this will hurt the users. The contest readme says about WitchV1 "we have found that liquidations have not been as fair as we would have liked. More often than not, liquidated users have lost all their collateral". Therefore it seems you might want to not liquidate more than necessary.

Proof of Concept

For liquidators, the auction mechanism gives out less collateral than debt payed at the beginning of the auction:

// inkOut = (artIn / totalArt) * totalInk * (p + (1 - p) * t)

(where t is % of time elapsed)

Therefore, according to the parameters used, a liquidator buying collateral may end up putting the vault over the collateralization ratio. At that point, the vault is not in a state to be liquidated anymore, but it's auction is still ongoing. Liquidators have no incentive to cancel it, and may just continue bidding, buying more of the user's collateral, making him lose even all of it (according to the auction parameters).

(Additionally, there's a side case where a user might repay his debt, and liquidators can front run his cancel tx to continue liquidating him - but that might be less of an issue as Yield expects users to know what they're doing.)

Revert in payFYToken and payBase if cauldron.level(vaultId) >= 0. You can even cancel the auction at that stage but that's going the extra mile.

#0 - HickupHH3

2022-07-18T14:32:54Z

I argue for both sides in my QA report - L01: Vaults that are over-collateralised after partial liquidation are possibly subject to further liquidations.

One can say that it is the liquidator's right to continue liquidations as the vault was under-collateralised in the first place, but it could also be seen as a bug.

#1 - alcueca

2022-07-21T10:28:34Z

Duplicate of #40

#2 - PierrickGT

2022-07-28T15:26:17Z

Downgraded to QA Report since this issue is related to a design decision.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter