The Ajna protocol is a non-custodial, peer-to-peer, permissionless lending, borrowing and trading system that requires no governance or external price feeds to function.
Block adding/move quote token to buckets with price above any existing auction price.
Purpose
addQuoteToken() and moveQuoteToken() will now revert if the price of the target bucket exceeds the
price of the liquidation at the head of the queue. Also, when auctions are added the queue, the
threshold price is max-ed with the tail (if any), forcing that the threshold prices (and hence auction prices)
are increasing.
This prevents users from adding liquidity to a bucket and immediately arbTaking-ing an auction, eliminating
attack and greifing vectors involving the bond payoffs and take penalties.
Solves what we internally have called Dmitrii - 9, an issue discovered by @dmitriia (although not eligible for the Sherlock report) ->
**Summary of the Vulnerability:**
The code outlines a scenario where a borrower can exploit the auction mechanism post-default to incur minimal penalties and unfairly benefit at the expense of the lender (kicker). This is achieved by the borrower exiting the auction early at an artificially high price, avoiding significant taker penalties, and causing collateral damage to the lender. The penalty paid by the borrower is negligible compared to the advantage gained, rendering the penalty almost irrelevant.
Borrower exploits the situation by depositing into a high price bucket.
Borrower takes from the bucket, reducing their penalty significantly.
Borrower removes a large portion of the collateral at an inflated price.
Post-removal, the lender's position is significantly weakened, with minimal gains.
Borrower ends up with a minor loss in USDC and almost no loss in WETH.
Lender gains are marginal compared to the potential loss incurred.
Analysis:
The borrower controls the collateral price, impacting the distribution between borrower and taker. However, when the borrower and taker are the same, the price becomes irrelevant.
The taker penalty, which should be a deterrent, is reduced to an insignificant amount due to the borrower's control over the collateral price.
The kicker (lender) faces a substantial loss of bond, while the borrower benefits by virtually eliminating the penalty at a negligible cost.
The potential for this exploit increases if issue #16 mentioned is fixed, allowing borrowers to execute this strategy more easily and atomically.
This vulnerability creates an imbalance in the protocol, favoring borrowers who default and strategically manipulate the auction process, while significantly disadvantaging lenders who face the brunt of the collateral damage. The protocol needs to address this imbalance to ensure fair and secure interactions between all parties involved.
## Impact
<!-- State technical consequences of the change, whether beneficial or detrimental. For example:
_Small increase in `removeQuoteToken` gas cost._
If the change does not affect deployed contracts, feel free to leave _none_. -->
## Tasks
- [ ] Changes to protocol contracts are covered by unit tests executed by CI.
- [ ] Protocol contract size limits have not been exceeded.
- [ ] Gas consumption for impacted transactions have been compared with the target branch, and nontrivial changes cited in the _Impact_ section above.
- [ ] Scope labels have been assigned as appropriate.
- [ ] Invariant tests have been manually executed as appropriate for the nature of the change.
Description
Block adding/move quote token to buckets with price above any existing auction price.
Purpose
addQuoteToken()
andmoveQuoteToken()
will now revert if the price of the target bucket exceeds the price of the liquidation at the head of the queue. Also, when auctions are added the queue, the threshold price ismax
-ed with the tail (if any), forcing that the threshold prices (and hence auction prices) are increasing. This prevents users from adding liquidity to a bucket and immediatelyarbTaking
-ing an auction, eliminating attack and greifing vectors involving the bond payoffs and take penalties.Solves what we internally have called Dmitrii - 9, an issue discovered by @dmitriia (although not eligible for the Sherlock report) ->
Link an example of the issue: https://github.com/ajna-finance/contracts/pull/981/files#diff-e59157bfa5bad910c2f5c2a00cfba7d222f0ad6f1969eb5ab4b2fbd22903b951R212
Sudo Code Representation of the Attack:
Lender adds liquidity to the pool.
Borrower draws a large debt from the pool.
Time skip of 100 days.
Lender initiates a kick due to default.
Borrower exploits the situation by depositing into a high price bucket.
Borrower takes from the bucket, reducing their penalty significantly.
Borrower removes a large portion of the collateral at an inflated price.
Post-removal, the lender's position is significantly weakened, with minimal gains.
Borrower ends up with a minor loss in USDC and almost no loss in WETH.
Lender gains are marginal compared to the potential loss incurred.
Analysis:
This vulnerability creates an imbalance in the protocol, favoring borrowers who default and strategically manipulate the auction process, while significantly disadvantaging lenders who face the brunt of the collateral damage. The protocol needs to address this imbalance to ensure fair and secure interactions between all parties involved.