[web3] 88mph Function Initialization Bug Fix Postmortem. This is a postmortem of a vulnerability… | by Immunefi | Oct, 2021 | Medium
medium.com
Published on medium.com
88mph
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.
Context
88mph is a DeFi protocol whose pools accept deposits and represent them as NFTs. The NFT contract on the platform is initialised through an init() function. That function is meant to set up the contract once, at deployment time, and the ownership it establishes carries the privilege of minting pool deposit NFTs and burning any user's NFT deposit through the mint() and burn() functions.
This is a review of a bug fix: a critical vulnerability in three specific pools, CRV:RENWBTC, CRV:STETH and yaLink, disclosed to Immunefi on June 7 by whitehat Ashiq Amien, a security researcher at iosiro.
Setup
The relevant preconditions are properties of the deployed contracts themselves:
- The
init()function in the NFT contract was callable by anyone. - It could be called more than once.
The vulnerable contracts listed in the report are:
- 88mph yaLINK Pool Deposit: [redacted]
- 88mph yaLINK Pool: [redacted]
- 88mph Harvest CRV:STETH Pool Deposit: [redacted]
- 88mph Harvest CRV:STETH Pool: [redacted]
- 88mph Harvest CRV:RENWBTC Pool Deposit: [redacted]
- 88mph Harvest CRV:RENWBTC Pool: [redacted]
Finding it
The init() function, used to initialise the NFT contract, was missing an onlyOwner modifier, and there was also no initializer modifier to prevent a re-initialisation. In other words, the function was unprotected and callable multiple times, by anyone.
The function was unprotected and callable multiple times by anyone.
Exploitation
Step 1: take ownership of the NFT contract
Because init() had no access control and no one-shot guard, a malicious user could call it and take ownership of the NFT contract. The report does not include the exact call or its arguments.
Step 2: use the ownership privileges
Ownership came with the privilege of minting pool deposit NFTs and burning any user's NFT deposit, using the mint() and burn() functions. This gave a malicious attacker access to any user's NFTs and deposits.
Step 3: side effects on pool accounting
Additionally, if a malicious user minted NFTs through this method, pool functions such as internal _deposit() or internal _fund() could break temporarily or permanently.
Root cause
The mistake was in the NFT contract's initialisation design: init() lacked both an onlyOwner modifier and an initializer modifier that would have made it callable only once. The init() function lacked an onlyOwner modifier and an initializer modifier, so anyone could call it more than once and take ownership of the NFT contract.
Impact
The vulnerability would have allowed a malicious user to steal $6.5m in tokens, mostly in crvRenWBTC. Beyond theft, the attacker would have had access to any user's NFTs and deposits, and minting NFTs through this path could break internal _deposit() or internal _fund() temporarily or permanently.
Fix
88mph's contracts are not by default pausable or upgradeable, so there was no built-in switch to stop the attack. During the assessment phase, Duncan Townsend, CTO of Immunefi, reviewed the code and suggested pausing the contracts by:
- deploying a dummy minter contract that reverted on every call, and
- setting the minter to that contract.
This pause method prevented frontrunning the whitehack and bought enough time to carefully capture all the funds and transfer them to the 88mph multisig wallet. The whitehack was executed on June 8th at 9:46pm UTC at the following address: [redacted]. Shortly after, 88mph returned all the funds to their rightful owners.
88mph is deploying its v3 platform soon, which will deprecate the affected contracts, so no immediate code fix is needed. For public education, the report lists at least three ways the bug could have been fixed in the code itself:
- Use a constructor instead of an
init()function. - Add an
onlyOwnermodifier. - Add an initializer modifier to make the
init()function only callable once.
88mph paid a bounty of $42,069 to iosiro at the request of the whitehat. The 88mph bug bounty program will be increased to $100,420.69 with the launch of v3.
Variants to test
- Initialiser functions on live contracts: look for
init(),initialize()or similar setup functions and check whether they carry an owner check and a one-shot guard. A positive result is a successful call from an account that is not the deployer, especially a second call after the contract is already in use. - Ownership-granting setup paths: trace what the initialiser sets, such as owner, minter or admin roles, and whether those roles reach mint, burn or transfer functions over user assets. A positive result is a role that lets an arbitrary caller move or destroy other users' tokens.
- Contracts without pause or upgrade mechanisms: check whether an emergency stop exists. Where it does not, the report's dummy-minter technique, pointing a privileged role at a contract that reverts on every call, is a way to neutralise the privileged path while funds are moved.
- Accounting functions downstream of NFT minting: check
internal _deposit()andinternal _fund()style functions for assumptions about who can mint. A positive result is a state that breaks deposits or funding temporarily or permanently after unauthorised minting.
What happened, in plain words
88mph is a DeFi protocol. DeFi, short for decentralised finance, is software that runs on a blockchain (here, Ethereum) and lets people deposit crypto tokens, lend them, borrow them or earn interest, without a bank in the middle. A protocol like 88mph organises this into pools: a pool is a shared pot of money that many users pay into, and the protocol keeps track of who put in what.
88mph represents each user's deposit as an NFT. An NFT (non-fungible token) is a unique digital token on the blockchain; unlike a currency coin, each one is distinct and can be owned by exactly one address. Think of it as a numbered claim ticket: whoever holds the ticket owns the deposit behind it. The part of the platform that creates and destroys these tickets is called the NFT contract. A contract is a program that lives on the blockchain at a fixed address and runs automatically when someone sends it a transaction.
That NFT contract is set up once, at deployment time (deployment means publishing the program to the blockchain), by a setup function called init(). The setup step records who owns the contract. Ownership is not cosmetic: the owner is allowed to create new deposit tickets with a function called mint() and to destroy any user's ticket with a function called burn().
On 7 June, a security researcher named Ashiq Amien, working at iosiro, reported to Immunefi (a platform that runs bug bounty programmes, where companies pay people for finding flaws in their software) that this setup function in three specific pools, CRV:RENWBTC, CRV:STETH and yaLink, could be called by anyone, and more than once. That meant a stranger could run the setup step themselves, become the owner, and then mint or burn tickets at will. The report says this would have allowed the theft of $6.5m in tokens, mostly in crvRenWBTC.
88mph reacted quickly: it paused the affected contracts, moved all user funds to safety in a coordinated rescue known as a whitehack (a hack performed by the good guys, with the project's cooperation, to get funds away from attackers before an attacker takes them), and later returned the money to its owners. The researcher received a bounty of $42,069, paid at the whitehat's request.

The image is the article's header, showing the title "88mph Function Initialization Bugfix Review" and the Immunefi byline with a reading time of 3 minutes and the date Jun 14, 2021.
The vulnerable contracts
A blockchain address is like a street address for a program or an account: a long string starting with 0x. The report lists six contracts that were affected, three pools and the three matching deposit contracts:
- 88mph yaLINK Pool Deposit: [redacted]
- 88mph yaLINK Pool: [redacted]
- 88mph Harvest CRV:STETH Pool Deposit: [redacted]
- 88mph Harvest CRV:STETH Pool: [redacted]
- 88mph Harvest CRV:RENWBTC Pool Deposit: [redacted]
- 88mph Harvest CRV:RENWBTC Pool: [redacted]
Each line pairs a pool (where the money sits) with its deposit contract (which issues the NFT tickets for that pool).
Finding it
Two small pieces of code were missing from init().
The first is an onlyOwner modifier. A modifier is a small condition attached to a function that must be true before the function body runs; onlyOwner means "only the contract's owner may call this". Without it, the door has no lock.
The second is an initializer modifier, a guard that records that setup has already happened and refuses any second call. Without it, the same setup step can be repeated forever.
Put together, the function was unprotected and callable multiple times, by anyone. The function was unprotected and callable multiple times by anyone.
How an attacker would have used it
Step 1: take ownership of the NFT contract
Because init() had no access control and no one-shot guard, a malicious user could simply call it and become the owner of the NFT contract. The report does not include the exact call or the arguments it takes.
Step 2: use the ownership privileges
Ownership came with the right to mint pool deposit NFTs and to burn any user's NFT deposit, through mint() and burn(). In everyday terms: the attacker could print new claim tickets and destroy other people's tickets. That gave access to any user's NFTs and deposits.
Step 3: side effects on pool accounting
There was a second, quieter consequence. If a malicious user minted NFTs this way, pool functions such as internal _deposit() or internal _fund() could break temporarily or permanently. Accounting code is the part of a contract that keeps the books: who deposited how much, and how much the pool holds. The report says these functions could break temporarily or permanently.
Root cause
The mistake was in how the NFT contract was initialised. init() had neither an onlyOwner modifier nor an initializer modifier that would have made it callable only once. Nothing in the contract's own defences stopped a second, attacker-initiated setup, and the ownership that setup granted was enough to reach mint() and burn(), the functions that operate on user deposit tickets.
Impact
The vulnerability would have allowed a malicious user to steal $6.5m in tokens, mostly in crvRenWBTC. Beyond the theft, the attacker would have had access to any user's NFTs and deposits, and minting NFTs through this path could break internal _deposit() or internal _fund() temporarily or permanently.
The fix
88mph's contracts are not pausable or upgradeable by default. Pausable means the team can flip a switch that makes the contract refuse to do anything; upgradeable means the code itself can be replaced. Neither existed here, so there was no built-in emergency stop.
During the assessment phase, Duncan Townsend, CTO of Immunefi, reviewed the code and suggested a way to pause the contracts anyway:
- deploy a dummy minter contract that reverts on every call, and
- set the minter to that contract.
To unpack that: a minter is the role or address allowed to create tokens. "Reverts" means the program refuses the transaction and undoes it, like a cashier saying no and handing your money back. By pointing the minter role at a contract whose only behaviour is to say no, the team made the privileged path unusable without touching the rest of the system.
Why was that necessary? Because of frontrunning. In a blockchain, transactions wait in a public queue before they are processed, and anyone can see them and pay more to have their own transaction processed first. If the team had simply started moving funds, an attacker watching the queue could have slipped in ahead of them. Neutralising the minter first removed the attacker's route in, and bought enough time to carefully capture all the funds and transfer them to the 88mph multisig wallet. A multisig wallet is a wallet that needs several people to approve a transaction before it goes through, so no single key can move the money.
The whitehack was executed on 8 June at 9:46pm UTC at the following address: [redacted]. Shortly afterwards, 88mph returned all the funds to their rightful owners.
88mph is deploying its v3 platform soon, which will deprecate the affected contracts, so no immediate code fix is needed. Deprecate means the old contracts are retired and replaced. For public education, the report lists at least three ways the bug could have been fixed in the code itself:
- Use a constructor instead of an
init()function. A constructor is a special function that runs exactly once, automatically, when the contract is deployed, so there is no separate setup step for anyone to call later. - Add an
onlyOwnermodifier, so only the owner can run the setup. - Add an initializer modifier to make the
init()function callable only once.
88mph paid a bounty of $42,069 to iosiro at the request of the whitehat. The 88mph bug bounty programme will be increased to $100,420.69 with the launch of v3.
What to look for in other projects
If you are learning to review contracts, the report points at four patterns worth checking:
- Initialiser functions on live contracts. Look for
init(),initialize()or similar setup functions and check whether they carry an owner check and a one-shot guard. A positive result is a successful call from an account that is not the deployer, especially a second call after the contract is already in use. - Ownership-granting setup paths. Trace what the initialiser sets, such as owner, minter or admin roles, and whether those roles reach mint, burn or transfer functions over user assets. A positive result is a role that lets an arbitrary caller move or destroy other users' tokens.
- Contracts without pause or upgrade mechanisms. Check whether an emergency stop exists. Where it does not, the dummy-minter technique from this report, pointing a privileged role at a contract that reverts on every call, is a way to neutralise the privileged path while funds are moved.
- Accounting functions downstream of NFT minting. Check
internal _deposit()andinternal _fund()style functions for assumptions about who can mint. A positive result is a state that breaks deposits or funding temporarily or permanently after unauthorised minting.
Glossary
- Blockchain: a shared, append-only record of transactions, maintained by many computers, where entries cannot easily be changed after the fact.
- Bug bounty: a programme that pays people for reporting security flaws responsibly instead of exploiting them.
- Burn: a function that destroys a token, here a user's deposit NFT.
- Constructor: a function that runs once automatically when a contract is deployed.
- Contract: a program stored on a blockchain at a fixed address that runs when transactions are sent to it.
- DeFi: decentralised finance, financial software running on a blockchain without a central intermediary.
- Deploy: to publish a program to the blockchain so it becomes live.
- Deprecate: to retire something in favour of a replacement.
- Frontrunning: seeing a pending transaction in the public queue and getting your own transaction processed first.
- Initializer modifier: a guard that allows a setup function to run only once.
- Modifier: a condition attached to a function that must hold before the function body runs.
- Multisig wallet: a wallet that requires several people to approve a transaction before it executes.
- NFT: non-fungible token, a unique digital token on a blockchain owned by one address; here it acts as a claim ticket for a deposit.
- onlyOwner: a modifier meaning only the contract's owner may call the function.
- Pausable: a contract property that lets the team make it refuse all activity on demand.
- Pool: a shared pot of deposited funds managed by a protocol.
- Revert: to refuse a transaction and undo it.
- Upgradeable: a contract property that lets its code be replaced after deployment.
- Whitehack: a rescue hack performed with the project's cooperation to move funds away from attackers.
- Whitehat: a security researcher who finds and reports flaws to help the project rather than to exploit them.