Open howlbot-integration[bot] opened 4 months ago
Valid finding.
Medium is more appropriate due to the below reasons.
allCreditPositionsForSaleDisabled = false
.hansfriese marked the issue as satisfactory
hansfriese changed the severity to 2 (Med Risk)
hansfriese marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/AccountingLibrary.sol#L62-L82 https://github.com/code-423n4/2024-06-size/blob/8850e25fb088898e9cf86f9be1c401ad155bea86/src/libraries/actions/Compensate.sol#L118-L145
Vulnerability details
Any credit position
forSale
set by the lender can be overridden to betrue
by their borrower with Compensate.Impact
Any credit position can be forcibly sold with the help of its borrower. This will be executed only when have expected profit, for example, when lender's curve is not null and is above the market it is profitable to buy credit from them (lend to them at above market rates), but they might block it with the lack of free collateral and the
forSale = false
flag, which can be overridden by the corresponding borrower of this credit position. The impact of this forced sale is proportional to interest rate volatility and can be substantial. There are no additional prerequisites for the setup.Proof of Concept
createDebtAndCreditPositions
creates credit positions withforSale == true
:AccountingLibrary.sol#L62-L82
This can be done on demand for any credit position by the borrower of the corresponding debt position, by running Compensate with
params.creditPositionToCompensateId == RESERVED_ID
, which will create new position withforSale == true
and substitute the existing lender position with it:Compensate.sol#L118-L145
Then it can be then bought with BuyCreditMarket:
BuyCreditMarket.sol#L79-L8
Tools Used
Manual Review
Recommended Mitigation Steps
Consider passing the flag to
createDebtAndCreditPositions()
indicatingforSale
flag to be set, which be passed from the existing credit in Compensate.sol#L139, so it won't be changed.Assessed type
Other