Incorrect minted
value calculation: The burn
function in the SmartVaultV3
contract doesn't account for fees, leading to underestimation of the minted
value. In the SmartVaultV3
contract, the burn
function subtracts only the _amount
from minted, but it doesn't add the fee
as the mint
function does. This leads to an inconsistency where minted
doesn't accurately reflect the total amount of tokens burned and the fee, because the actual minted = minted - _amount + fee
. This impacts over 56% of relevant functions in the SmartVaultV3
contract and some functions in SmartVaultManagerV5
contract, such as undercollateralised, fullyCollateralised, canRemoveCollateral, calculateMinimumAmountOut, liquidate, mint, removeAsset, swap and tokenURI
.
It is possible to handle fees by following the same approach as the mint function.
If minted
is calculated like minted = minted - _amount
, it will underestimate minted
, which will affect the results of functions such as undercollateralised, fullyCollateralised, canRemoveCollateral, and calculateMinimumAmountOut
, and in turn directly affect the results of more than 56% of relevant functions in SmartVault
contract and tokenURI
function in the SmartVaultManagerV5
. This will lead to the vault being unable to provide normal services and user funds being lost, as follows in detail:
1.The calculateMinimumAmountOut
function will return an incorrect amount. This means that users may swap the less amount of collateral than they could.
SmartVaultV3::calculateMinimumAmountOut
2.The undercollateralised
function will return false even if the vault is undercollateralised, because the minted
is underestimated and the actual minted > maxMintable
. This means that the vault may not be liquidated by the functions of liquidate, liquidateNative, liquidateERC20
, even though it has insufficient collateral to cover its debt.
SmartVaultV3::undercollateralised
In addition, the fullyCollateralised
function will return true even if the vault is not fully collateralised. This means that users may mint
new collateral and could not burn
more amount even though the vault has insufficient collateral to support it.
[SmartVaultV3::fullyCollateralised]https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L156C1-L158C6
[SmartVaultV3::mint]https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L162C9-L162C65
3.The canRemoveCollateral
function will return true even if the vault could not allow users to remove collateral. This means that users may be able to remove collateral even though they do not have the right to do so.
SmartVaultV3::canRemoveCollateral
SmartVaultV3::removeCollateralNative, removeCollateral, removeAsset
4.If minted
is underestimated, the data in the status
struct will be incorrect. This will prevent the SmartVaultManagerV5
contract from generating the correct NFTMetadata through tokenURI
function.
Inaccurate liquidation: Undercollateralized vaults might not be liquidated, risking debt coverage.
Incorrect minting/burning: Users could mint new collateral when insufficient, or be unable to burn more when needed.
Unauthorized collateral removal: Users could remove collateral without the right to do so.
Incorrect swap amounts: Users might swap less collateral than intended.
Incorrect NFTMetadata: The SmartVaultManagerV5
contract might generate inaccurate NFTMetadata.
Manual
Modify burn
function: Add the fee to the minted
calculation: minted = minted - _amount + fee
.
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.