Closed code423n4 closed 1 year ago
https://github.com/code-423n4/2023-05-venus/blob/8be784ed9752b80e6f1b8b781e2e6251748d0d7e/contracts/VToken.sol#L776
Users can call VToken.mint to deposit underlying and mint vTokens.
VToken.mint
vTokens
The amount of vToken minted is proportional to the actualMintAmount of underlying they transferred:
vToken
actualMintAmount
776: uint256 mintTokens = div_(actualMintAmount, exchangeRate);
The issue is that this operation can result in mintTokens == 0 if actualMintAmount < exchangeRate
mintTokens == 0
actualMintAmount < exchangeRate
As there is no further check that mintTokens != 0, the call will succeed, without updating accountTokens[minter]
mintTokens != 0
accountTokens[minter]
A user in this situation will have lost their underlying - as their accountTokens[user] mapping would still be 0.
accountTokens[user]
Note that based on the high value of the initial ExchangeRateMantissa
PoolRegistry.sol 290: 10**(underlyingDecimals + 18 - input.decimals),
This situation is possible
Manual Analysis
Add a check at the end of _mintFresh to ensure mintTokens != 0
_mintFresh
Math
0xean changed the severity to QA (Quality Assurance)
0xean marked the issue as grade-c
Lines of code
https://github.com/code-423n4/2023-05-venus/blob/8be784ed9752b80e6f1b8b781e2e6251748d0d7e/contracts/VToken.sol#L776
Vulnerability details
Users can call
VToken.mint
to deposit underlying and mintvTokens
.The amount of
vToken
minted is proportional to theactualMintAmount
of underlying they transferred:The issue is that this operation can result in
mintTokens == 0
ifactualMintAmount < exchangeRate
As there is no further check that
mintTokens != 0
, the call will succeed, without updatingaccountTokens[minter]
Impact
A user in this situation will have lost their underlying - as their
accountTokens[user]
mapping would still be 0.Note that based on the high value of the initial ExchangeRateMantissa
This situation is possible
Tools Used
Manual Analysis
Recommended Mitigation Steps
Add a check at the end of
_mintFresh
to ensuremintTokens != 0
Assessed type
Math