Platform: Code4rena
Start Date: 08/05/2023
Pot Size: $90,500 USDC
Total HM: 17
Participants: 102
Period: 7 days
Judge: 0xean
Total Solo HM: 4
Id: 236
League: ETH
Rank: 85/102
Findings: 1
Award: $51.68
🌟 Selected for report: 0
🚀 Solo Findings: 0
51.6843 USDC - $51.68
https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L180-L185 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L743-L791 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L743-L791 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L1463-L1483 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L1476 https://github.com/code-423n4/2023-05-venus/blob/main/contracts/VToken.sol#L1421-L1424
Attacker can steal funds from normal user under certain condition.
Consider following scenario :
When totalSupply = 0,
Attacker deposits few underlying to mint themself 1 vTOken, they basically own 100% share of the pool with this 1 vToken.
Now Attacker supplies huge amount of underlying tokens to the vToken contract indirectly(with ERC20 transfer, not via mint function).
Any, subsequent normal users trying to mint vToken by depositing the underlying won't be minted any share as amount of token to be minted is calculated as mintAmount/exchangeRate, and ExchangeRate is calculated via underlying.balanceOf(address(this)), which has been artificially increased as mentioned in previous step, so the result will be zero for most users. so users underlying will be transfer to contract but they will be zero share.
Now after some such transaction, attacker withdraws their and pools only 1 vToken, claiming entire amount of underlying asset own by pool, (which includes their indirect supply as well as victim users funds).
This is pretty common issue in protocol related to lending/borrowing protocol.
Manual Review
Best solution as the protocol is not deployed yet is to burn few shares as soon as first shares are minted, alternatively you can manually few shares to ensure totalsupply never goes to zero.
Other
#0 - c4-judge
2023-05-17T12:03:33Z
0xean marked the issue as duplicate of #314
#1 - c4-judge
2023-06-05T14:08:36Z
0xean marked the issue as satisfactory
#2 - c4-judge
2023-06-05T14:37:43Z
0xean changed the severity to 2 (Med Risk)