Skip to content
Smart contracts Write-up Advanced

Moonbeam Missing Call Check Bug Fix Review

A missing check in Moonbeam's precompiled contracts allowed a malicious contract to use DELEGATECALL to impersonate another contract's address and access its precompile storage, potentially stealing native assets. An attacker could trick a victim contract into granting maximum allowance to the attacker's address, enabling theft of funds.

immunefi.com

Published on immunefi.com

On May 27th, whitehat pwning.eth submitted a missing call check critical vulnerability to the Moonbeam network via Immunefi, demonstrating the possibility of a direct theft of the native assets, such as Moonriver (MOVR) and Moonbeam (GLMR), which were deployed using pre-compiled contracts. The Moonbeam team estimated…

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 precompiled contracts did not check whether an incoming call was a DELEGATECALL or a regular CALL, allowing a malicious contract to impersonate the caller.

Impact

The vulnerability could have allowed direct theft of native assets such as Moonriver (MOVR) and Moonbeam (GLMR), with an estimated impact of up to $100m, but no user funds were lost due to the whitehat's disclosure.

What the attacker needed

Victim interacts with malicious contract; or victim contract allows arbitrary calls

The fix

The vulnerability was fixed by adding a check to revert DELEGATECALL to custom precompiled contracts in the EVM.

How it was found

  1. Attacker deploys a malicious smart contract that uses DELEGATECALL to a precompile, passing the victim's address as msg.sender.
  2. Victim contract (e.g., a DEX with a callback) is tricked into calling the malicious contract.
  3. The malicious contract calls the precompile via DELEGATECALL, which sees the victim's address as the caller and grants allowance to the attacker's beneficiary.
  4. Attacker calls transferFrom to move the victim's tokens to the beneficiary.

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.

In blockchain systems like Ethereum, smart contracts can call each other in different ways. One way, called DELEGATECALL, lets a contract run another contract's code but keep its own identity and storage. The bug was that Moonbeam's special built-in contracts (precompiles) didn't check if they were being called this way, so a malicious contract could pretend to be another contract and steal its tokens.

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.