When calling the emergencyClose function to close a strategy vault, because of an emergency reason. The amount which the strategy vault owes the lending vault is calculated, and this amount is sent to the lending vault. If there is not enough funds left, the function will revert and therefore all funds are stuck inside the contract. Normally it should not be possible that there are less funds left than the strategy vault owes the lending vault, but this is an emergency function, and therefore it should expect the worst.
The emergencyClose function calculates how much the strategy vault owes the lending vault and tries to repay this amount to the lending vault:
As we can see in the calcRepay function, it does not take into account the possibility that there are not enough funds in the contract to fully repay the lending vault:
Therefore, if the emergency reason has led to a situation where the funds in the contract are less than the amount that the strategy vault owes to the lending vault, the attempt to return all funds to the lending vault will revert and therefore a DoS of the emergencyClose function occurs, which means that all funds remain stuck in the contract.
Here we can see the flow of the repay function which leads to a normal safeTransferFrom call without protection against such a revert:
All funds being stuck inside the contract as the emergencyClose function reverts.
Manual Review
If there are not enough funds to pay back the lenders fully than only pay as much as possible and do not try to pay them everything back.
Impact: Medium Likelihood: Low The keepers can send tokens directly before closing. Will leave for a sponsor's review but likely to invalidate.
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.