Revert Lend - zxriptor's results

A lending protocol specifically designed for liquidity providers on Uniswap v3.

General Information

Platform: Code4rena

Start Date: 04/03/2024

Pot Size: $88,500 USDC

Total HM: 31

Participants: 105

Period: 11 days

Judge: ronnyx2017

Total Solo HM: 7

Id: 342

League: ETH

Revert

Findings Distribution

Researcher Performance

Rank: 104/105

Findings: 1

Award: $3.35

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

3.3501 USDC - $3.35

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
sufficient quality report
edited-by-warden
:robot:_45_group
duplicate-222

External Links

Lines of code

https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Vault.sol#L696-L698

Vulnerability details

Impact

A user undergoing the liquidation process can front-run a call to the V3Vault.sol::liquidate by manipulating debtShares variable. This is possible due to the equality requirement of user's loan debtShares and LiquidateParams.debtShares at lines 696-698:

if (debtShares != params.debtShares) { revert DebtChanged(); }

To achieve that, a user can repay their loan with a minimal amount of tokens by calling V3Vault.sol::repay() function. This will cause debtShares update as can be seen in lines 990-991.

uint256 loanDebtShares = loan.debtShares - shares; loan.debtShares = loanDebtShares;

In this manner, a user can evade liquidation an unlimited number of times as long as it remains economically viable for them, potentially leading to bad debt for the protocol.

Proof of Concept

  1. Alice deposits and borrows X amount.
  2. The collateral price moves down, exposing Alice's loan to the possible liquidation.
  3. Bob the Liquidator executes liquidation of Alice's loan specifying debtShares of the loan as it is last seen on V3Vault contract.
  4. Alice executes the repay transaction with several wei of the token and a higher gas price. This leads debtShares of the loan to change (move down).
  5. Bob's transaction reverts, leaving Alice's loan unhealthy and not liquidated.

Tools Used

Manual review.

Remove debtShares equality check and rely solely on the loan health status.

Assessed type

Other

#0 - c4-pre-sort

2024-03-18T18:14:01Z

0xEVom marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-03-18T18:15:04Z

0xEVom marked the issue as duplicate of #231

#2 - c4-pre-sort

2024-03-22T12:02:52Z

0xEVom marked the issue as duplicate of #222

#3 - c4-judge

2024-03-31T14:47:29Z

jhsagd76 changed the severity to 2 (Med Risk)

#4 - c4-judge

2024-03-31T16:06:34Z

jhsagd76 marked the issue as satisfactory

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