Skip to content
Business logic Audit finding Intermediate

User can lose funds

If the reward token is mistakenly set to the staking token, the contract can pay out rewards using deposited funds, allowing early withdrawers to drain more than they deposited and leaving later users unable to withdraw. The report demonstrates this with a scenario where one user withdraws 105 while another is stuck.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain

If \_rewardToken is set as \_stakingToken by mistake then user funds would get lost (staking token will get sent as reward token). Need to be fixed for BaseRewardPool.sol as well.

Proof of Concept

  1. User A and B makes deposit of amount 100 each
  2. Owner calls addReward and queueNewRewards to add 1 reward amount with _rewardToken as stakingToken (by mistake)
  3. After some time reward is calculated as 5 for User A (total reward amount is same as staking amount which is 100+100+1).
  4. User A makes the withdraw and obtains 105 amount and now User B is stuck since contract does not have enough funds

Recommended Mitigation Steps

Add below check in constructor

require(_stakingToken!=_rewardToken, "Incorrect reward token");

jetbrain10 (veToken Finance) disagreed with severity and commented:

It’s set by owner, so there is no issue, but it is nice to have and it is a quick fix.

Alex the Entreprenerd (judge) commented:

The warden has shown how, due to a misconfiguration, the deposit token stakingToken could be transferred away to early withdrawers.

For end users the basic due diligence would be to ensure that the stakingToken is not added as reward.

Because the finding is contingent on a malicious admin / misconfiguration, I believe Medium Severity to be appropriate.


The original report as published on Code4rena, by csanuragjain. 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 constructor does not check that the staking token and reward token are different, so a misconfiguration allows rewards to be paid from deposited funds.

Impact

If the owner misconfigures the reward token, early withdrawers could take more than their deposit, leaving later users unable to withdraw their funds.

What the attacker needed

Owner sets reward token same as staking token

How it was found

  1. Two users each deposit 100 tokens.
  2. The owner adds a reward of 1 token, mistakenly using the staking token as the reward token.
  3. After some time, the reward for one user is calculated as 5 tokens.
  4. That user withdraws and receives 105 tokens, leaving the contract with insufficient funds for the other user.

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 staking contract holds users' deposits and pays rewards in a separate token. If the reward token is accidentally set to the same token as the deposits, the contract may use deposited money to pay rewards. Then the first person to withdraw can take more than they put in, and later users find the contract empty.

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 Anurag Jain

View all

63 more disclosed reports, best first.

More from veToken Finance 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.