Minimium Collateral Check Can Be Bypassed
The minimum collateral check was enforced only when borrowing USDS, not when withdrawing collateral, so a user could open a small loan and then withdraw collateral to fall below the threshold. This could leave small loans unliquidated, potentially causing bad debt in the protocol.
Submitted by Banditx0x, also found by Audinarey, Giorgio, and t0x1c
The minimum collateral is enforced to prevent a well known vulnerability - there is no incentive to liquidate small loans. Therefore the impact of this check being bypassed is the same - small loans will not be liquidated which can lead to bad debt in the protocol.
Proof of Concept
The minimum collateral is enforced in the when borrowing USDS, during the call to the maxBorrowableUSDS function. However this check is not applied when the user withdraws collateral. Therefore, a loan with small collateral can be created by:
- depositing collateral greater than the minimum collateral
- taking out a small loan
- withdrawing collateral so that the position is now under the minimum collateral threshold.
Why small loans are an issue:
The liquidation reward is based off a flat 5% of the collateral being liquidated. There is no minimum cap to the liquidation fee.
Let’s have an example where gas costs are $5. The collateral being liquidated needs to be $100 USDS or more for the liquidation costs to be worth the reward.
However, a loan that is worth $100 at liquidation is actually worth far more than that upon time of opening. For example, opened at the minimum collateral factor of 200%, the loan is actually worth slightly less than $200 when it was opened, and then decreased to $100. With even lower-leverage positions with 400% CF, it is reasonable that position sizes are $400 or more upon time of opening.
Recommended Mitigation Steps
The minimum collateral should be enforced on withdrawals whenever a user has an active USDS loan.
Picodes (Judge) decreased severity to Medium and commented:
To me medium severity is more appropriate here under “leak value with a hypothetical attack path with stated assumptions, but external requirements” and “broken functionality”.
Indeed this could lead to bad debt but the attack is hardly profitable at any point in time as the gas costs to setup small loans is expensive (you need to add collateral, borrow, repay, withdraw) and unless the oracle is flawed you can’t have a guarantee that the attack will profitable.
othernet-global (Salty.IO) acknowledged and commented:
The stablecoin framework: /stablecoin, /price_feed, WBTC/WETH collateral, PriceAggregator, price feeds and USDS have been removed: https://github.com/othernet-global/salty-io/commit/88b7fd1f3f5e037a155424a85275efd79f3e9bf9
Status: Mitigation confirmed. Full details in reports from t0x1c, zzebra83, and 0xpiken.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the minimum collateral threshold was checked only in the borrow path and not in the collateral withdrawal path.
Impact
Small loans may not be liquidated, which could lead to bad debt in the protocol, though the judge noted the attack is hardly profitable because of gas costs and oracle assumptions.
What the attacker needed
An active USDS loan; ability to deposit and withdraw collateral
The fix
The minimum collateral should be enforced on withdrawals whenever a user has an active USDS loan; the stablecoin framework was later removed.
How it was found
- Deposit collateral greater than the minimum collateral.
- Take out a small loan.
- Withdraw collateral so that the position is now under the minimum collateral threshold.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A lending protocol requires borrowers to keep a minimum amount of collateral so that if they default, the loan is large enough to be worth liquidating. Here, the check was only done when borrowing, not when withdrawing collateral, so a borrower could shrink their position below that minimum. Small loans may then never be liquidated, leaving the protocol with unpaid debt.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.