When a successful withdrawal is executed from the GMX market but the callback fails, the status is set to withdraw_failed. Subsequently, the keeper calls the processWithdrawFailure function, which incorrectly handles this event by reborrowing again and then adding liquidity.
The processWithdrawFailure function is invoked after a withdrawal failure. In this scenario, it reborrows the previous repayTokenAAmt and repayTokenBAmt from the lendingVault contract and subsequently adds liquidity again:
This logic is flawed because there is no need to re-borrow in the withdraw_failed status. The status being withdraw_failed indicates the contract's initial failure to repay the debt, and the withdrawn tokens are already held by the strategyVault. The withdraw_failed status is set only when the try block inside processWithdraw fails:
In the try block, the processWithdraw function from GMXProcessWithdraw library is called, where the vault repays the debt:
However, the flawed logic results in the contract borrowing the same amounts again, mistakenly assuming the debt has already been repaid.
Another issue arises when there is insufficient funds in the lending contract for borrowing, as the system does not check the capacity beforehand. This results in repeated reverting transactions, causing the contract to remain stuck in the withdraw_failed status. Continuous calls from the keeper only result in wasted gas without any progress.
Increased risk of bad debt in case of strategy losses.
Higher interest costs for lending.
Potential contract getting stuck at withdraw_failed status.
vs code
manual review
there is no need for reborrowing . just add liquidity again with the token held by the strategyVault
Impact: High Likelihood: High Overlending is caused due to unnecessary re-borrow on processWithdrawFailure. Assumption that the repayment had gone because it was in try-catch is incorrect.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.