ajna-finance / ajna-core

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.
https://www.ajna.finance/
Other
31 stars 11 forks source link

Block addqt above auction price #997

Closed mattcushman closed 11 months ago

mattcushman commented 11 months ago

Description

Block adding/move quote token to buckets with price above any existing auction price.

Purpose

Link an example of the issue: https://github.com/ajna-finance/contracts/pull/981/files#diff-e59157bfa5bad910c2f5c2a00cfba7d222f0ad6f1969eb5ab4b2fbd22903b951R212

Sudo Code Representation of the Attack:

  1. Lender adds liquidity to the pool.

  2. Borrower draws a large debt from the pool.

  3. Time skip of 100 days.

  4. Lender initiates a kick due to default.

  5. Borrower exploits the situation by depositing into a high price bucket.

  6. Borrower takes from the bucket, reducing their penalty significantly.

  7. Borrower removes a large portion of the collateral at an inflated price.

  8. Post-removal, the lender's position is significantly weakened, with minimal gains.

  9. Borrower ends up with a minor loss in USDC and almost no loss in WETH.

  10. 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.



## 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.
ith-harvey commented 11 months ago

Would like the typographic issues resolved before merging.

Think I got them all here -> https://github.com/ajna-finance/contracts/pull/997/commits/d5d0ca7f591d47db3b0e44789d1ef48673d1a3f9