Skip to content
Business logic Audit finding Intermediate

Rewards squatting - setting rewards in different ERC20 tokens opens various economic attacks.

The contract allows the rewards token to be changed, so users can front-run the change to claim old rewards if the new token is less valuable, or let their balance roll into the new token if it is more valuable. This creates an economic attack and prevents the protocol from later issuing a more valuable reward token.

moose-code Follow

Originally disclosed on Code4rena

Submitted by moose-code, also found by hickuphh3

Users essentially have an option to either claim currently earned reward amounts on future rewards tokens, or the current rewards token.

Although stated on line 84, it does not take into account the implications the lock in this contract will have on the future value of new tokens able to be issued via rewards.

Smart users will monitor the mempool for setRewards transactions. If the new reward token (token b) is less valuable than the old reward token (token a), they can front run this transaction by calling claim. Otherwise, they let their accrued ‘token a’ roll into rewards of of the more valuable ‘token b’.

Given loads of users will likely hold these tokens from day 1, there will potentially be thousands of different addresses squatting on rewards.

Economically, and given the above, it makes sense that the value of new reward tokens, i.e. ‘token b’ should always be less than that of ‘token a’. This is undesirable in a rewards token contract, as there is no reliable way to start issuing a more valuable token at a later stage, unless exposing yourself to a major risk of reward squatting.

i.e. You could not issue a more valuable token in future (for example, if we wanted to run a rewards period issuing an asset like WETH rewards for 10 days) after first initially issuing DAI as a reward. This hamstrings flexibility of the contract.

P.s. This is one of the slickest contracts I’ve read. Love how awesome it is.Just believe this should be fixed, then its good to go.

It is true you could probably write a script to manually go call claim on thousands of squatting token addresses but this is a poor solution.

Recommend instead, that a simple mapping pattern could be used with an index mapping to a reward cycle with a reward token and a new accumulative etc. Users would likely need to be given a period a to claim from old reward cycles before their token balance could no longer reliably used to calculate past rewards. The would still be able to claim everything up until their last action (even though this may be before the rewards cycle ended).

alcueca (Yield) confirmed:

Thanks! I agree that allowing to change the rewards token is just too troublesome.

alcueca (Yield) patched:

Fix

The original report as published on Code4rena, by moose-code. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract allows the rewards token to be changed without accounting for users' ability to time claims around the change.

Impact

The protocol cannot reliably issue a more valuable reward token later without exposing itself to reward squatting, limiting flexibility.

What the attacker needed

Users hold reward tokens; owner can change rewards token; attacker can monitor mempool

The fix

The rewards token should not be changeable; instead, use a mapping with reward cycles so users can claim from old cycles for a period.

How it was found

  1. Monitor the mempool for setRewards transactions.
  2. If the new reward token is less valuable, front-run the transaction by calling claim.
  3. Otherwise, let accrued rewards roll into the more valuable new token.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A rewards contract pays users in a token. The owner can switch which token is used for rewards. If the new token is worth less, users can quickly claim their old rewards before the switch. If the new token is worth more, they can wait and get more value. This makes it hard to ever switch to a better token.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by moose-code

View all

1 more disclosed report, best first.

More from Yield Witch v2 contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.