Skip to content
Smart contracts Write-up Advanced

How a Memory Corruption Bug Almost Drained $800M From the Polygon

A vulnerability chain in the Polygon Plasma bridge allowed an attacker to forge withdrawal proofs by combining an early-stopping bug in the Merkle Patricia Trie verifier with an out-of-bounds read in the RLP parser, enabling the theft of the full bridge balance of $800 million in POL.

Officer's Notes Follow

Published on medium.com

In July 2024, blockchain security firm Hexens disclosed a critical vulnerability chain in the Polygon Plasma bridge, the bridge that held all locked POL between Ethereum and Polygon PoS. The bugs allowed an attacker to forge a proof that any arbitrary event had happened on the Polygon chain, including a Withdraw event…

Officer's Notes, on medium.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 Merkle Patricia Trie verifier allowed stopping at an extension node instead of requiring a leaf node, and the RLP parser failed to check that child elements stayed within the parent's bounds, together enabling forged proofs.

Impact

An attacker could forge a withdrawal proof and drain the full $800 million bridge balance in one transaction, but the vulnerability was fixed before any funds were lost.

What the attacker needed

None

How it was found

  1. Find a block on Polygon with an extension node hash that passes the parsing requirements (done once, reusable forever)
  2. Build an exit payload that includes the real checkpoint proof and block proof (these are legitimate) but replaces the transaction receipt with the extension node hash and truncates the MPT proof path
  3. Append a zero-byte buffer plus the forged Withdraw log at the end of the payload
  4. Call startExitWithBurntTokens on the ERC20PredicateBurnOnly contract
  5. The MPT verifier accepts the hash as the “receipt” (bug #1)
  6. The external call to WithdrawManager loads the full payload into memory, then “deallocates” it

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.

The Polygon bridge lets users move tokens between two blockchains. To withdraw tokens, you must prove that you burned them on the other chain. The bridge checks this proof using two pieces of code: one that verifies the proof and one that reads the data. Both had mistakes that, when combined, let an attacker create a fake proof and steal all the money locked in the bridge.

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.