Limit index isn't checked in repayDebt, so user control is void
The repayDebt function accepts a limit index meant to protect the borrower against an unfavourable change in the pool's price, but the check enforcing that limit only ran when collateral was also being pulled. A borrower whose strategy depended on the resulting price move could therefore have a repayment execute at a worse level than they intended.
repayDebt() resulting LUP _revertIfPriceDroppedBelowLimit() check is not performed in the case of pure debt repayment without collateral pulling.
Vulnerability Detail
LUP will move (up or no change) as a result of debt repayment and repayDebt() have limitIndex_ argument. As a part of multi-position strategy a user might not be satisfied with repay results if LUP has increased not substantially enough.
I.e. there is a user control argument, it is detrimental from UX perspective to request, but not use it, as for any reason a borrower might want to control for that move: they might expect the final level to be somewhere, as an example for the sake of other loans of that borrower.
Impact
Unfavorable repayDebt() operations will be executed and the borrowers, whose strategies were dependent on the realized LUP move, can suffer a loss.
Probability of execution is high (no prerequisites, current ordinary behavior), while the probability of the following loss is medium, so placing the severity to be medium.
if (vars.pull) {
// only intended recipient can pull collateral
if (borrowerAddress_ != msg.sender) revert BorrowerNotSender();
// an auctioned borrower in not allowed to pull collateral (even if collateralized at the new LUP) if auction is not settled
if (result_.inAuction) revert AuctionActive();
// calculate LUP only if it wasn't calculated in repay action
if (!vars.repay) result_.newLup = Deposits.getLup(deposits_, result_.poolDebt);
>> _revertIfPriceDroppedBelowLimit(result_.newLup, limitIndex_);
Tool used
Manual Review
Recommendation
Consider adding the same check in the repayment part:
If no repay or pull it looks ok to skip the check to save gas.
Discussion
grandizzy
Repayment can only make the position less risky, so don't see a need for frontrunning/stale TX protection. Documentation should clearly state this behavior.
0xffff11
I do see the issue being valid. As sponsor said, they don't see a need to implement a safeguard, but the watson demonstrated that users can suffer a loss if non-favorable repays are executed. Could keep the medium.
// revert if no amount to pull or repay
if (!vars.repay && !vars.pull) revert InvalidAmount();
so later check not needed
dmitriia
Looks ok
The original report as published on Sherlock, by hyh. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the limit check was placed inside the collateral-pull branch only, so the repayment-only path never compared the new price against the caller's limit index.
Impact
Repayments that the borrower would consider unfavourable could execute, and borrowers whose strategies relied on the realised price move could suffer a loss; the reporter rates this medium because it needs no special conditions but the resulting loss is only moderately likely.
What the attacker needed
None beyond normal pool use
The fix
The team agreed to change the behaviour and a pull request was opened so the limit index takes effect in all cases; a reviewer then noted the check should only run when a repay or pull actually happens, and the team replied that the no-op case already reverts earlier.
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.
Generating the AI write-up for this report.
This usually takes about a minute. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
In a lending pool, repaying debt changes an internal price that other positions depend on. The function lets the caller set a limit so the transaction fails if that price moves too far, but the code only enforced the limit when collateral was withdrawn at the same time. So a repayment on its own could go through even when the price ended up somewhere the borrower did not want.
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.