MorpheusAI

MorpheusAI
Foundry
22,500 USDC
View results
Submission Details
Severity: high
Invalid

An attacker can grief any user off their rewards due to accounting issues and missing permission

Vulnerability Details

The issue is that rewards received depends on the pools totaldeposit, rate and last update, however in the stake function, the rate is calculated and updated with the old totaldeposit and then updates the pool totalDeposit with the current one:

// Update pool data
poolData.lastUpdate = uint128(block.timestamp);
poolData.rate = currentPoolRate_;
poolData.totalDeposited += amount_;

This means when a claim happens right after a stake opeation, the calculation below in _getCurrentPoolRate:

uint256 rewards_ = getPeriodReward(poolId_, poolData.lastUpdate, uint128(block.timestamp));
return poolData.rate + (rewards_ * PRECISION) / poolData.totalDeposited;

when attempting to get reward would receive a lesser rate due to the totalDeposited having increased and lastUpdated as well but rate still being the old rate.

Proof Of Concept

  • An attacker notices this and calls stake to increase the pool's totalDeposited and lastUpdated but pool rate is set with the calculation from the previous totalDeposited

  • Then attacker calls claim for a user.

  • User receive very low rewards due to division by a larger pool totalDeposited.

Impact

An attacker can grief any user off their rewards due to accounting issues and missing permission

Recommendations

Two things:

1: Update the rate to have the current rate for the current pool totalDeposited

- poolData.lastUpdate = uint128(block.timestamp);
- poolData.rate = currentPoolRate_;
- poolData.totalDeposited += amount_;
+ poolData.totalDeposited += amount_;
+. poolData.rate = _getCurrentPoolRate(poolId_);
+ poolData.lastUpdate = uint128(block.timestamp);

2: Also ensure user gives permission to who can call claim() for them

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.