Closed code423n4 closed 2 years ago
There is no sandwich attack opportunity as the amount received only varies based on the pool exchange rate. And the pool exchange rate cannot be manipulated by an attacker.
Given the consideration that the > hypothetical < loss would be through front-running, High Severity would be out of the question.
Per the sponsor reply I went and checked redeem
and how exchangeRate
is used, and have to agree that beside getWithdrawalFee
there is no obvious way in which value would be lost through a migration.
Because the finding is contingent on demonstrating a change in exchangeRate that would be:
In lack of a POC, I can't help but mark the finding invalid
Note that a frontrunner can increase the exchangeRate, but doing so doesn't seem to be favourable nor it was fully explained by the warden
@GalloDaSballo lp.exchangeRate() -> lp.totalUnderlying() -> vault.getTotalUnderlying() -> vault._availableUnderlying() which is an abstract function. A vault may consider some portion of deposited funds as 'unavailable', and therefore the exchange rate may be manipulatable by deposit/withdrawal actions by an attacker
@IllIllI000 with the information made available on the finding, I don't believe any specific exploit was detailed.
You can make the argument (post-fact) that _availableUnderlying
can be improperly coded, potentially causing losses to a hypothetical vault, however that wouldn't be an issue with migration
but a potential issue with how Vault Accounting is handled.
I don't believe you were making that argument in the original finding, so with the information I had at the time, given the fact that no POC showed how to manipulate the exchangeRate, I don't think the finding has proven that migrate
is dangerous to end users
Lines of code
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/zaps/PoolMigrationZap.sol#L59 https://github.com/code-423n4/2022-05-backd/blob/1136e0cdc8579614a33832fe2a21785d60aac19b/protocol/contracts/pool/LiquidityPool.sol#L527-L559
Vulnerability details
Impact
Users will lose all of their money when they migrate by calling
PoolMigrationZap.migrate()
Proof of Concept
https://github.com/code-423n4/2022-05-backd/blob/2a5664d35cde5b036074edef3c1369b984d10010/protocol/contracts/zaps/PoolMigrationZap.sol#L52-L59
The
redeem()
call above on line 59 callsredeem(<amount>, 0)
where zero indicates the minimum amount to receieve from the redemption:https://github.com/code-423n4/2022-05-backd/blob/1136e0cdc8579614a33832fe2a21785d60aac19b/protocol/contracts/pool/LiquidityPool.sol#L527-L559
Because the
minRedeemAmount
is set to zero, users will be vulnerable to sandwich attacks, and will lose all of their money.The mechanics of the attack are:
The attacker pockets the difference between the amount of tokens the user should have been able to redeem, and the actual amount they were able to redeem.
Tools Used
Code inspection
Recommended Mitigation Steps
Supply the original amount, with some small percentage removed for slippage, instead of zero