Stricter preconditions for payInterest #623
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
InterestReceiverStakeBuyback
andInterestReceiverSwapToETH
contracts both utilize Uniswap in order to swap tokens. There is some slippage protection, but no protection against price manipulation is built in.Because the
payInterest
function in theInterestConnector
is external and permissionless, anyone can call it at any time. Therefore, once enough interest accrues, one could take out a flash loan to manipulate the relevant Uniswap pools and callpayInterest
to make a profit.Additionally, even if
payInterest
weren't permissionless, it is possible for the Uniswap call inonInterestReceived
to fail, leaving the tokens sitting in theInterestReceiver
contract. Here, theonInterestReceived
function is external and permissionless, meaning it's once again prone to being attacked via price manipulation.Furthermore, assuming the interest payment was not callable by untrusted parties at all, it would still be possible to manipulate the price by sandwiching that transaction between two others, either by chance or by collusion with miners.
The fix is to disable ability of storing tokens on the interest receiver contract and introduces extra EOA-only check to payInterest method.
This reduces the risk of possible price manipulations, since it is no longer possible to use flash-loans to perform an attack.
Front-running of the transaction is considered less dangerous, as it requires a much higher attack cost (at least 2 Uniswap transactions gas fees + 2 slippage and swap fees).