Skip to content
DoS Audit finding Intermediate

Rewards distribution can be disrupted by a early user

The reward accounting variable reward.integral is a uint128 that can overflow if an early user deposits a tiny amount of LP tokens and then transfers a large amount of reward tokens to the contract. This overflow disrupts the rewards distribution and can prevent other users from depositing.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

ConvexStakingWrapper.sol#L184-L188

if (_supply > 0 && d_reward > 0) {
    reward.integral =
        reward.integral +
        uint128((d_reward * 1e20) / _supply);
}

reward.integral is uint128, if an early user deposits with just 1 Wei of lpToken, and make _supply == 1, and then transferring 5e18 of reward_token to the contract.

As a result, reward.integral can exceed type(uint128).max and overflow, causing the rewards distribution to be disrupted.

Recommended Mitigation Steps

Consider wrap a certain amount of initial totalSupply at deployment, e.g. 1e8, and never burn it. And consider using uint256 instead of uint128 for reward.integral. Also, consider lower 1e20 down to 1e12.

ryuheimat (Concur) confirmed

Alex the Entreprenerd (judge) decreased severity to Medium and commented:

The warden has shown a way to break the uint128 accounting system in place.

This is contingent on frontrunning the pool and depositing a small amount to cause the division to fail. Additionally, this will cause a DOS that prevents other people from depositing.

I believe that this could be unstuck by continuously (via loop) depositing 1 wei as to slowly increase the totalSupply again.

Mitigation can be attained by either refactoring or by ensuring that the first deposit is big enough (18 decimals) to keep numbers to rational values.

Because the finding is contingent on a setup and because tokens will be rescuable, I believe Medium Severity to be more appropriate.


The original report as published on Code4rena, by WatchPug. 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

Impact

The overflow disrupts rewards distribution and can cause a denial of service that prevents other users from depositing, though the judge notes it is contingent on a setup and tokens will be rescuable.

What the attacker needed

Attacker can front-run the pool; attacker deposits 1 Wei of lpToken; attacker transfers reward tokens

The fix

The contract should be fixed by wrapping a certain amount of initial totalSupply at deployment (e.g., 1e8) and never burning it, using uint256 instead of uint128 for reward.integral, and lowering the 1e20 constant to 1e12.

How it was found

  1. An early user deposits 1 Wei of lpToken, making _supply equal to 1.
  2. The user transfers 5e18 of reward_token to the contract.
  3. The reward.integral calculation overflows because the division by _supply (1) produces a value larger than uint128 can hold.

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.

This report is about a smart contract that distributes rewards. The contract uses a number to track rewards, but that number has a maximum size. If someone makes the total deposits very small and then adds a lot of reward tokens, the number can overflow and break the reward system, stopping others from depositing.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by WatchPug

View all

197 more disclosed reports, best first.

More from Concur Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.