Closed c4-bot-6 closed 8 months ago
gzeon-c4 marked the issue as primary issue
gzeon-c4 marked the issue as sufficient quality report
gzeon-c4 marked the issue as insufficient quality report
totalAssets not used to calculate deposit
JustDravee marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L609-L631
Vulnerability details
Impact
Discounted shares can be minted during a flashloan callback re-entrancy which can drain the protocol.
Proof of Concept
During a flashloan, the
ibt
is transferred out before the flashloan callback, which decreases thetotalAssets
of the PrincipalToken vault:With a lower
totalAssets
, the attacker can deposit a lower amount of assets to get the same amount of shares. This essentially drains the protocol because when the assets are redeposited after the flashloan is returned, those shares can be redeemed for a larger amount of assets.Tools Used
Manuel review
Recommended Mitigation Steps
Add a non-reentrant modifier to external functions in
PrincipalToken.sol
Assessed type
Reentrancy