Open sherlock-admin opened 1 year ago
We think this should be a low. Although not explicitly stated that this can happen in docs it is assumed based off of implementation. We were aware, not concerned.
I can still see the issue as a medium. Sponsor agreed to the issue and it has some impact on the fees that lender might have to pay
Looks ok, but shouldn't the same flag be introduced to moveQuoteToken()
, e.g.:
if (vars.fromBucketPrice >= lup_ && vars.toBucketPrice < lup_) {
+ if (params_.revertIfBelowLup) revert PriceBelowLUP();
movedAmount_ = Maths.wmul(movedAmount_, Maths.WAD - _depositFeeRate(poolState_.rate));
}
Looks ok, but shouldn't the same flag be introduced to
moveQuoteToken()
, e.g.:if (vars.fromBucketPrice >= lup_ && vars.toBucketPrice < lup_) { + if (params_.revertIfBelowLup) revert PriceBelowLUP(); movedAmount_ = Maths.wmul(movedAmount_, Maths.WAD - _depositFeeRate(poolState_.rate)); }
implemented with https://github.com/ajna-finance/contracts/pull/918 Beside suggested change there are 2 additional updates
MoveQuoteParams
struct moved from inline in order to avoid stack too deep errorPool
contract size by reading structs in view functions only onceimplemented with ajna-finance/contracts#918
Looks ok, the above logic now added.
Escalate for 10 USDC.
As the sponsor said
We think this should be a low. Although not explicitly stated that this can happen in docs it is assumed based off of implementation. We were aware, not concerned.
this is more like a feature request, not bug
Escalate for 10 USDC.
As the sponsor said
We think this should be a low. Although not explicitly stated that this can happen in docs it is assumed based off of implementation. We were aware, not concerned.
this is more like a feature request, not bug
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
I think this issue is a valid medium. It points to a possible scenario where a lender has to pay fees and lose interest against their will due to no slippage protection, which can be exploited through MEV attack. Because of the scenario of lenders losing funds against their intention, it should be medium.
Due to the fact that slippage can be exploited to cause users to lose funds, this should be considered a vulnerability or bug.
I disagree with the escalation in this case. I think it should be a medium. Despite being a design decision, allows users to be exposed to high slippage on behalf of their decision.
Looks like valid medium to me, the probability of the material impact can be said to be medium, so is the impact itself.
implemented with ajna-finance/contracts#918
Looks ok, the above logic now added.
Moving sign-off by @dmitriia here for clarity.
Result: Medium Has duplicates Considering a valid medium based on the above comments
branch_indigo
medium
Lenders lose interests and pay deposit fees due to no slippage control
Summary
When a lender deposits quote tokens below the minimum of LUP(Lowest Utilization Price) and HTP(Highest Threshold Price), the deposits will not earn interest and will also be charged deposit fees, according to docs. When a lender deposits to a bucket, they are vulnerable to pool LUP slippage which might cause them to lose funds due to fee charges against their will.
Vulnerability Detail
A lender would call
addQuoteToken()
to deposit. This function only allows entering expiration time for transaction settlement, but there is no slippage protection.In LenderActions.sol,
addQuoteToken()
takes currentDepositsState
in storage and currentpoolState_.debt
in storage to calculate spot LUP prior to deposit. And this LUP is compared with user input bucketindex_
to determine if the lender will be punished with deposit fees. The deposit amount is then written to storage.It should be noted that current
deposits_
andpoolState_.debt
can be different from when the user invoked the transaction, which will result in a different LUP spot price unforeseen by the lender to determine deposit fees. Even though lenders can input a reasonable expiration timeexpirty_
, this will only prevent stale transactions to be executed and not offer any slippage control.When there are many lenders depositing around the same time, LUP spot price can be increased and if the user transaction settles after a whale lender which moves the LUP spot price up significantly, the user might get accidentally punished for depositing below LUP. Or there could also be malicious lenders trying to ensure their transactions settle at a favorable LUP/HTP and front-run the user transaction, in which case the user transaction might still settle after the malicious lender and potentially get charged for fees.
Impact
Lenders might get charged deposit fees due to slippage against their will with or without MEV attacks, lenders might also lose on interest by depositing below HTP.
Code Snippet
https://github.com/ajna-finance/ajna-core/blob/e3632f6d0b196fb1bf1e59c05fb85daf357f2386/src/base/Pool.sol#L146-L150
https://github.com/ajna-finance/ajna-core/blob/e3632f6d0b196fb1bf1e59c05fb85daf357f2386/src/libraries/external/LenderActions.sol
https://github.com/ajna-finance/ajna-core/blob/e3632f6d0b196fb1bf1e59c05fb85daf357f2386/src/libraries/external/LenderActions.sol#L195
Tool used
Manual Review
Recommendation
Add slippage protection in Pool.sol
addQuoteToken()
. A lender can enable slippage protection, which will enable comparing depositindex_
withlupIndex
in LenderActions.sol.