Skip to content
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

splitReinvest() can be front run #312

Closed
code423n4 opened this issue Dec 1, 2021 · 2 comments
Closed

splitReinvest() can be front run #312

code423n4 opened this issue Dec 1, 2021 · 2 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/RewardReinvestor.sol#L78-L90

function splitReinvest(uint256 rewardLiquidity) external {
    _retrieveReward(rewardLiquidity);

    uint256 rewardBalance = rewardToken.balanceOf(address(this));

    rewardToken.safeTransfer(address(dexHandler), rewardBalance.div(2));

    dexHandler.buyMalt();

    _bondAccount(msg.sender);

    emit SplitReinvest(msg.sender, rewardLiquidity);
  }

The current implementation of splitReinvest() provides no parameter for slippage control, making them vulnerable to front-run attacks.

POC

  1. Alice calls splitReinvest();
  2. Bob can send a DEX buy tx with a higher gas price to buy a large amount of MALT;
  3. Alice end up getting much less LP token than expected, due to the price impact created by Bob;
  4. Bob sells all the MALT bought before for profit.

Recommendation

Consider adding a amountOutMin parameter.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Dec 1, 2021
code423n4 added a commit that referenced this issue Dec 1, 2021
@0xScotch 0xScotch added the duplicate This issue or pull request already exists label Dec 10, 2021
@0xScotch
Copy link
Collaborator

#219

@GalloDaSballo
Copy link
Collaborator

Duplicate of #219

@GalloDaSballo GalloDaSballo marked this as a duplicate of #219 Jan 9, 2022
@CloudEllie CloudEllie added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants