This repository has been archived by the owner on Sep 1, 2024. It is now read-only.
0xDetermination - Fees aren't distributed properly for positions with multiple lenders, causing loss of funds for lenders #41
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
0xDetermination
high
Fees aren't distributed properly for positions with multiple lenders, causing loss of funds for lenders
Summary
Fees distributed are calculated according to a lender's amount lent divided by the total amount lent, which causes more recent lenders to steal fees from older lenders.
Vulnerability Detail
The fees distributed to each lender are determined by the following calculation (https://github.com/sherlock-audit/2024-02-leverage-contracts/blob/main/wagmi-leverage/contracts/LiquidityBorrowingManager.sol#L546-L549):
The above is from
harvest()
;repay()
calculates the fees similarly. Becauseborrow()
doesn't distribute fees, the following scenario will occur when a borrower increases an existing position:harvest()
orrepay()
is called, and the new lender is credited with some of the previous fees earned by the other lenders due to the fees calculation. Other lenders lose fees.This scenario can naturally occur during the normal functioning of the protocol, or a borrower/attacker with a position with a large amount of uncollected fees can maliciously open a proportionally large loan with an attacker to steal most of the fees.
Also note that ANY UDPATE ISSUE? LOW PRIO
Impact
Loss of funds for lenders, potential for borrowers to steal fees.
Code Snippet
https://github.com/sherlock-audit/2024-02-leverage-contracts/blob/main/wagmi-leverage/contracts/LiquidityBorrowingManager.sol#L546-L549
Tool used
Manual Review
Recommendation
A potential fix is to harvest fees in the borrow() function; the scenario above will no longer be possible.
The text was updated successfully, but these errors were encountered: