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

Patch bug that could enable draining rewards by front-running a new token deployment #219

Closed
ewilz opened this issue Nov 22, 2021 · 1 comment · Fixed by #218
Closed

Comments

@ewilz
Copy link
Member

ewilz commented Nov 22, 2021

It was brought to our attention that a hard-to-produce, but important bug exists in the canonical staker contract.
The createIncentive() function does not check that the rewardToken address contains bytecode when invoking transferFrom() via address.call(). This means it's possible to successfully create an incentives program for a reward amount without actually transferring any token over if the rewardToken address has no bytecode.

Potential Attack

  1. Front-run the deployment of a new token by starting an incentives program with the token address before that token address has bytecode. An incentives program is created without any reward tokens having been transferred.
  2. Wait for a legitimate incentives program to be created after the token has been deployed.
  3. The attacker could then drain the reward token amount from the legitimate incentives program, given the malicious incentives program has ended, therefore allowing the incentive creator to collect all unclaimed rewards.

Solution

Check that the rewardToken contract has bytecode before creating an incentive with that token. This will ensure that createIncentive will revert if the full token amount is not transferred to the staker contract.

@moodysalem
Copy link
Contributor

@invocamanman reported this issue to the security email address, and we are in the process of paying out a bug bounty. Thank you for the report, @invocamanman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants