Malicious strategist could deny borrowers from repaying loan and force liquidation by setting a extremely high vault fee
A malicious strategist can set an extremely high vault fee when creating a public vault, causing loan repayment to revert due to an integer conversion failure. This can force borrowers into liquidation, making them lose their NFT collateral.
Submitted by peakbolt, also found by kaden and caventa
https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L605 https://github.com/code-423n4/2023-01-astaria/blob/main/src/test/TestHelpers.t.sol#L471
Issue: A malicious strategist can deny the repayment of loans by setting a extremely high vault fee during creation of a public vault. The high vault fee will cause a revert due to a failed integer conversion using SafeCastTo88(). This will lead to forced liquidation of the borrowers when the loans expire outstanding, making them lose their NFT collaterals. (Vault fee is an incentive awarded to strategist on each loan repayment, where a percentage of the interest payment is allocated to the strategist, in terms of vault shares.)
High Likelihood: The strategist could target borrowers by refinancing outstanding loans and transfering the loans to his high fee vault, which does not require the borrowers’ consents. This can be achieved as refinancing can be done by anyone and the logic only checks for better interest rate and duration, but not the vault fee. The borrowers will not be aware of the issue, until they attempt to repay the loan. Furthermore, the strategist could specifically target loans that are about to expire, giving little reaction time for borrowers to report the issue.
Financial gain: With the ability to force a liquidation, the strategist can possibly stand to gain financially (e.g. by refinancing the loans with a lower liquidationInitialAsk and then bid for the NFT collateral (with high gas fee) during liquidation.
Note: Even if there are no lenders willing to lend to the vault due to the high vault fee, the strategist still can lend to its own vault to faciliate the refinance.
Proof of Concept
The bug can be replicated by changing the test case. Set vaultFee parameter to a high value (e.g. 1e13) as shown below in the file /src/test/TestHelpers.t.sol. Then run testBasicPublicVaultLoan() in AsteriaTest.t.sol. In this test case, we will see that the strategist could create a public vault with a high vaultFee as there is no validation check for it. And any borrower could still proceed to deposit their collateral and take loan without any issues as the vaultFee is only accessed upon loan repayment.
function _createPublicVault(
address strategist,
address delegate,
uint256 epochLength
) internal returns (address publicVault) {
vm.startPrank(strategist);
//bps
publicVault = ASTARIA_ROUTER.newPublicVault(
epochLength,
delegate,
address(WETH9),
//uint256(0)
uint256(1e13), //to replicate the bug, change vaultFee parameter from 0 to a high value like 1e13
false,
new address[](0),
uint256(0)
);
vm.stopPrank();
}
https://github.com/code-423n4/2023-01-astaria/blob/main/src/test/TestHelpers.t.sol#L471 https://github.com/code-423n4/2023-01-astaria/blob/main/src/test/AstariaTest.t.sol#L90
However, when the borrower attempts to repay the loan, it will revert due to a failed integer conversion. As the fee is too high, convertToShare() will return a value that exceeds 88-bit, causing the safeCastTo88() in _handleStrategistInterestReward() to fail.
uint88 feeInShares = convertToShares(fee).safeCastTo88();
https://github.com/code-423n4/2023-01-astaria/blob/main/src/PublicVault.sol#L605
Recommended Mitigation Steps
Check that the vaultFee is within a reasonable range during vault creation.
SantiagoGregory (Astaria) confirmed via duplicate issue #378
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The vault fee is not validated when the vault is created, allowing a value so large that converting it to shares overflows an 88-bit integer and reverts.
Impact
Borrowers cannot repay their loans, leading to forced liquidation and loss of their NFT collateral; the strategist could gain financially by bidding on the collateral during liquidation.
What the attacker needed
Attacker is a strategist; attacker creates a vault with high fee; borrower takes a loan from that vault
The fix
The vault fee should be validated to be within a reasonable range during vault creation.
How it was found
- Create a public vault with a very high vault fee (e.g., 1e13) using the newPublicVault function.
- Have a borrower deposit collateral and take a loan from that vault.
- When the borrower tries to repay, the transaction reverts because the fee calculation overflows an 88-bit integer.
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.
A strategist is someone who manages a vault where people lend money. They can set a fee that is taken when a borrower repays. If the fee is set extremely high, the code that calculates the fee fails and the repayment transaction is blocked. The borrower cannot repay, so the loan expires and the borrower's collateral (an NFT) can be taken.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.