Code is vulnerable to ERC4626 first depositor shares manipulation exploit #384
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-275
satisfactory
satisfies C4 submission criteria; eligible for awards
Lines of code
https://github.com/code-423n4/2022-11-redactedcartel/blob/9e9bb60f117334da7c5d851646a168ca271575fc/src/vaults/PirexERC4626.sol#L80
Vulnerability details
Proof of Concept
The normal ERC4626 implementation (which is not changed in the repository) has a vulnerability which can result in the first depositor stealing every subsequent depositor’s funds.
It works like this:
underlying
, so he now holds 1 shareunderlying
underlying
balance for his 1 share (the total supply) resulting in him stealing all of Alice’s deposited tokensImpact
This can result in a 100% loss of deposited funds for users of the protocol, so it should be of High severity.
Recommendation
Revert when the shares minted are zero.
The text was updated successfully, but these errors were encountered: