Skip to content
Smart contracts Write-up Advanced

Moonbeam Astar And Acala Library Truncation Bug Fix Review 1m Payout

A truncation bug in the Frontier library caused the EVM to truncate the 256-bit msg.value to 128 bits, so a transfer of 2^128 would be treated as zero by the runtime but as 2^128 by smart contracts. An attacker could mint unlimited wrapped tokens and drain wrapper contracts and DEXes.

immunefi.com

Published on immunefi.com

On June 27th, whitehat pwning.eth submitted a critical bug report that impacted the Polkadot ecosystem via Immunefi, demonstrating the possibility of minting valid but depegged wrapped 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

Likely the transfer function truncated the 256-bit msg.value to 128 bits, creating a discrepancy between what the EVM reported and what the runtime actually transferred.

Impact

The bug could have allowed an attacker to mint unlimited wrapped tokens and drain all wrapped tokens and DEXes on Moonbeam, Astar, and Acala, with estimated potential losses of nearly $200m; the report was patched before exploitation.

What the attacker needed

Ability to deploy a contract on Moonbeam; knowledge of the truncation bug

The fix

Moonbeam released Runtime 1606 which removed the truncation, and the library was patched.

How it was found

  1. Deploy the exploit contract onto the Moonbeam network with the address of the Wrapped MOVR contract.
  2. Call depositWMOVR() with msg.value=0, which evaluates to 2^128 + 0, so no MOVR is transferred because the value truncates to 0.
  3. Call withdrawMOVR(); the WMOVR contract believes 2^128 was deposited and allows withdrawal of 2^128 MOVR for only transaction fees.
  4. Profit.

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.

When you send cryptocurrency to a smart contract, the amount is stored as a large number. The bug caused the system to cut off the top part of that number, so a huge amount looked like zero to the system but like a huge amount to the contract. This let an attacker create fake wrapped tokens and steal real funds.

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.