Skip to content

Stricter preconditions for payInterest #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2021
Merged

Conversation

k1rill-fedoseev
Copy link
Member

@k1rill-fedoseev k1rill-fedoseev commented Aug 15, 2021

The InterestReceiverStakeBuyback and InterestReceiverSwapToETH 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 the InterestConnector 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 call payInterest to make a profit.

Additionally, even if payInterest weren't permissionless, it is possible for the Uniswap call in onInterestReceived to fail, leaving the tokens sitting in the InterestReceiver contract. Here, the onInterestReceived 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).

@k1rill-fedoseev k1rill-fedoseev added audit Items related to the security audits interest earning Items related to interest earning labels Aug 15, 2021
@k1rill-fedoseev k1rill-fedoseev self-assigned this Aug 15, 2021
@akolotov akolotov added the team-august-2021 Related to items found by ChainSecurity in the audit held in August of 2021 label Aug 16, 2021
@akolotov akolotov merged commit 7d4a0c6 into develop Aug 16, 2021
@akolotov akolotov deleted the audit/august2021/5.1 branch August 16, 2021 19:16
akolotov added a commit that referenced this pull request Sep 6, 2021
This update for the `master` branch contains the changes made to address findings discovered during a security audit:
 * [Fix] Stricter preconditions for payInterest (#623)
 * [Fix] Fix offset in comments (#624)
 * [Fix] Use fixed lower call gas limit (#627)
 * [Fix] Separate XDaiForeignBridge contract with compound and GSN support (#626)
 * [Fix] Update GSN interface (#628)
 * [Fix] Block ERC20 selectors in AMB requests (#630)
 * [Other] Bump package and contracts interfaces version prior to 6.0.0 (#629)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit Items related to the security audits interest earning Items related to interest earning team-august-2021 Related to items found by ChainSecurity in the audit held in August of 2021
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants