Submitted by jonah1005, also found by cmichel and itsmeSTYJ
The v3 vault treats all valid tokens exactly the same. Depositing 1M DAI would get the same share as depositing 1M USDT. User can withdraw their share in another token. Though theres withdrawalProtectionFee (0.1 percent), the vault is still a no slippage stable coin exchange.
Also, I notice that 3crvtoken is added to the vault in the test. Treating 3crvtoken and all other stable coins the same would make the vault vulnerable to flashloan attack. 3crv_token is an lp token and at the point of writing, the price of it is 1.01. The arbitrage space is about 0.8 percent and makes the vault vulnerable to flashloan attacks.
Though the team may not add crv_token and dai to the same vault, its design makes the vault vulnerable. Strategies need to be designed with super caution or the vault would be vulnerable to attackers.
Given the possibility of a flashloan attack, I consider this a high-risk issue.
The issue locates at the deposit function (Vault.sol#L147-L180).
The share is minted according to the calculation here
The share is burned at Vault.sol L217
Heres a sample exploit in web3.py.
Hardhat
Given the protocols scenario, I feel like we can take iearn tokens architect as a Ref. yDdai
yDai handles multiple tokens (cDai/ aDai/ dydx/ fulcrum). Though four tokens are pretty much the same, the contract still needs to calculate the price of each token.
Or, creating a vault for each token might be an easier quick fix.
Haz077 (yAxis) acknowledged
transferAndCall (yAxis) commented:
GalloDaSballo (judge) commented:
GalloDaSballo (judge) commented:
GalloDaSballo (judge) commented:
BobbyYaxis (yAxis) noted:
