Skip to content
Smart contracts Write-up Advanced

88mph Theft Of Unclaimed Mph Rewards Bug Fix Review

The vesting03 contract failed to update vestRewardPerTokenPaid when a user deposited, so users could deposit and immediately withdraw vested tokens, receiving rewards they had not earned. An attacker could drain most of the unclaimed MPH tokens from the contract.

immunefi.com

Published on immunefi.com

On September 25, 2022, 0xSzeth reported a high severity bug in 88mph’s vesting03 smart contract via Immunefi. This bug allowed some malicious users to drain the vesting contract of unclaimed MPH rewards (88mph tokens).

The author, on immunefi.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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

How it worked

Root cause

The createVestForDeposit function did not update vestRewardPerTokenPaid with the current rewardPerToken, so the earned calculation treated a new deposit as if it had been earning rewards for a long time.

Impact

An attacker could steal most of the 88mph tokens held in the vesting03 contract; the proof of concept showed around 3.66 ETH could be stolen.

What the attacker needed

Access to a flashloan provider; ability to interact with the contracts

The fix

The vulnerability was fixed by updating vestRewardPerTokenPaid with the current rewardPerToken when a user makes an initial deposit.

How it was found

  1. Flashloan WETH from Uniswap or AAVE.
  2. Call deposit() on the DInterest contract to deposit WETH.
  3. Call withdraw() on the vesting03 contract using the vestID from the deposit.
  4. Call withdraw() on the DInterest contract with true to withdraw the initial deposit early.
  5. Swap the 88mph tokens obtained from step 3 on Balancer or Uniswap.
  6. Repay the flashloan and fee.

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 write-up has not been written yet. The Original tab links to the source.

A smart contract lets people deposit money and earn rewards over time. A mistake meant that if you deposited and then immediately withdrew, the contract still gave you the full reward as if you had waited. This let someone take rewards that belonged to other users.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.