Skip to content
Smart contracts Write-up Advanced

Polygon Double Spend Bug Fix Review 2m Bounty

The Polygon Plasma Bridge's withdrawal verification allowed the same burn transaction to be exited multiple times because the branch mask in the exit proof could be encoded in many ways, each producing a different exit ID. An attacker could deposit funds, wait for the exit period, and then replay the exit with modified branch masks to drain up to 223 times the deposited amount from the bridge.

immunefi.com

Published on immunefi.com

Once in a while, the Immunefi triaging team receives a bug report that changes everything — a report that shows how vital bug bounty programs are, and how Immunefi helps to save hundreds of millions of dollars from being hacked. Such a bug report was submitted to Immunefi earlier this month.

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 withdrawal manager decoded the branch mask in two different ways: one decoder ignored part of the encoded value while the other used it to compute a unique exit ID, so multiple encodings of the same proof produced different exit IDs and bypassed replay protection.

Impact

An attacker could drain up to 223 times their deposit from the bridge, with around $850M at risk and a $100k deposit potentially yielding $22.3M in losses.

What the attacker needed

Funds to deposit on Polygon; wait seven days for exit validity

The fix

The fix was to check that the first byte of the encoded branch mask is 0x00 and not disregard it as an incorrect mask.

How it was found

  1. Deposit a large amount of ETH or tokens to Polygon through the Plasma Bridge.
  2. After the funds are confirmed on Polygon, start the withdrawal process.
  3. Wait seven days for the exit to become valid.
  4. Resubmit the exit payload but with a modified first byte of the branch mask.
  5. Repeat the resubmission up to 223 times with different values for the first byte of the HP-encoded path.
  6. Profit from the repeated exits.

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 blockchain bridge lets you move tokens between two blockchains. To withdraw tokens from Polygon back to Ethereum, you prove that you burned them on Polygon. The bridge checks this proof and gives you the tokens on Ethereum. The bug was that the proof could be slightly altered in many ways that the bridge still accepted, so the same burn could be used to withdraw tokens many times.

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.