Polygon Double Spend Vulnerability: Difference between revisions

From Quadriga Initiative Cryptocurrency Hacks, Scams, and Frauds Repository
Jump to navigation Jump to search
(Created page with "{{Imported Case Study|source=https://www.quadrigainitiative.com/casestudy/polygondoublespendvulnerability.php}} thumb|PolygonThe Polygon bridge allows users to cash funds from the Polygon side-chain back to Ethereum. As part of this mechanism, a smart contract hot wallet checks to see proof that the Polygon tokens are accurate. This smart contract hot wallet had a vulnerability where the same proof could be submitted up to 223 times, to withdraw 223...")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Imported Case Study|source=https://www.quadrigainitiative.com/casestudy/polygondoublespendvulnerability.php}}
{{Imported Case Study|source=https://www.quadrigainitiative.com/casestudy/polygondoublespendvulnerability.php}}
{{Unattributed Sources}}


[[File:Polygon.jpg|thumb|Polygon]]The Polygon bridge allows users to cash funds from the Polygon side-chain back to Ethereum. As part of this mechanism, a smart contract hot wallet checks to see proof that the Polygon tokens are accurate. This smart contract hot wallet had a vulnerability where the same proof could be submitted up to 223 times, to withdraw 223 times as much money. After launching a bug bounty program, a developer found the vulnerability and was rewarded with a $2m bounty. No funds were stolen.
[[File:Polygon.jpg|thumb|Polygon]]The Polygon bridge allows users to cash funds from the Polygon side-chain back to Ethereum. As part of this mechanism, a smart contract hot wallet checks to see proof that the Polygon tokens are accurate. This smart contract hot wallet had a vulnerability where the same proof could be submitted up to 223 times, to withdraw 223 times as much money. After launching a bug bounty program, a developer found the vulnerability and was rewarded with a $2m bounty. No funds were stolen.


This is a global/international case not involving a specific country.
This is a global/international case not involving a specific country.<ref name="blockthreat-5482" /><ref name="immunefimedium-6077" /><ref name="polygon-6075" /><ref name="polygon-6076" /><ref name="gerhardwagnermedium-6078" />


== About Polygon ==
== About Polygon ==
Line 72: Line 73:
!Description
!Description
|-
|-
|October 5th, 2021 12:00:00 AM
|October 5th, 2021
|Main Event
|Main Event
|Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here.
|Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here.
Line 80: Line 81:
|
|
|}
|}
== Technical Details ==
This section includes specific detailed technical analysis of any security breaches which happened. What specific software vulnerabilities contributed to the problem and how were they exploited?


== Total Amount Lost ==
== Total Amount Lost ==
Line 101: Line 105:
== Ongoing Developments ==
== Ongoing Developments ==
What parts of this case are still remaining to be concluded?
What parts of this case are still remaining to be concluded?
== Individual Prevention Policies ==
{{Prevention:Individuals:Placeholder}}
{{Prevention:Individuals:End}}
== Platform Prevention Policies ==
{{Prevention:Platforms:Placeholder}}
{{Prevention:Platforms:End}}
== Regulatory Prevention Policies ==
{{Prevention:Regulators:Placeholder}}


== Prevention Policies ==
{{Prevention:Regulators:End}}
Which policies could have prevented this event from happening?


== References ==
== References ==
[https://www.blockthreat.io/p/blockthreat-week-42-2021 No Title] (Jan 10)
<references><ref name="blockthreat-5482">[https://www.blockthreat.io/p/blockthreat-week-42-2021 No Title] (Jan 10, 2022)</ref>


[https://medium.com/immunefi/polygon-double-spend-bug-fix-postmortem-2m-bounty-5a1db09db7f1 Polygon Double Spend Bug Fix Postmortem 2m Bounty] (Jan 28)
<ref name="immunefimedium-6077">[https://medium.com/immunefi/polygon-double-spend-bug-fix-postmortem-2m-bounty-5a1db09db7f1 Polygon Double Spend Bug Fix Postmortem 2m Bounty] (Jan 28, 2022)</ref>


[https://polygon.technology/ Polygon | Ethereum's Internet of Blockchains] (Jan 29)
<ref name="polygon-6075">[https://polygon.technology/ Polygon | Ethereum's Internet of Blockchains] (Jan 29, 2022)</ref>


[https://polygon.technology/about/ About - Polygon | Ethereum's Internet of Blockchains] (Jan 29)
<ref name="polygon-6076">[https://polygon.technology/about/ About - Polygon | Ethereum's Internet of Blockchains] (Jan 29, 2022)</ref>


[https://gerhard-wagner.medium.com/double-spending-bug-in-polygons-plasma-bridge-2e0954ccadf1 https://gerhard-wagner.medium.com/double-spending-bug-in-polygons-plasma-bridge-2e0954ccadf1] (Jan 29)
<ref name="gerhardwagnermedium-6078">[https://gerhard-wagner.medium.com/double-spending-bug-in-polygons-plasma-bridge-2e0954ccadf1 https://gerhard-wagner.medium.com/double-spending-bug-in-polygons-plasma-bridge-2e0954ccadf1] (Jan 29, 2022)</ref></references>

Latest revision as of 19:50, 3 May 2023

Notice: This page is a freshly imported case study from the original repository. The original content was in a different format, and may not have relevant information for all sections. Please help restructure the content by moving information from the 'About' section to other sections, and add any missing information or sources you can find. If you are new here, please read General Tutorial on Wikis or Anatomy of a Case Study for help getting started.

Notice: This page contains sources which are not attributed to any text. The unattributed sources follow the initial description. Please assist by visiting each source, reviewing the content, and placing that reference next to any text it can be used to support. Feel free to add any information that you come across which isn't present already. Sources which don't contain any relevant information can be removed. Broken links can be replaced with versions from the Internet Archive. See General Tutorial on Wikis, Anatomy of a Case Study, and/or Citing Your Sources Guide for additional information. Thanks for your help!

Polygon

The Polygon bridge allows users to cash funds from the Polygon side-chain back to Ethereum. As part of this mechanism, a smart contract hot wallet checks to see proof that the Polygon tokens are accurate. This smart contract hot wallet had a vulnerability where the same proof could be submitted up to 223 times, to withdraw 223 times as much money. After launching a bug bounty program, a developer found the vulnerability and was rewarded with a $2m bounty. No funds were stolen.

This is a global/international case not involving a specific country.[1][2][3][4][5]

About Polygon

"Polygon is a protocol and a framework for building and connecting Ethereum-compatible blockchain networks. Aggregating scalable solutions on Ethereum supporting a multi-chain Ethereum ecosystem." "Polygon is an open source project built by decentralized team of contributors from all over the world."

"We envision an open, borderless world. A world in which people and machines collaborate and exchange value globally and freely, without gatekeepers or intermediaries. A world in which communities thrive, unconstrained by artificial borders and archaic regulations." "We don’t believe in traditional companies, hierarchy and management. Anyone is welcome to contribute code, ideas or anything else that can help make our vision a reality!"

"Polygon combines the best of Ethereum and sovereign blockchains into a full-fledged multi-chain system. Polygon solves pain points associated with Blockchains, like high gas fees and slow speeds, without sacrificing on security. This multi-chain system is akin to other ones such as Polkadot, Cosmos, Avalanche etc, but with at least three major upsides: (1) It is able to fully benefit from Ethereum’s network effects. (2) It is inherently more secure. (3) It is more open and powerful."

"Polygon combines the best of Ethereum and sovereign blockchains into an attractive feature set." "Ethereum is the blockchain development platform of choice, but it has limitations. Low Throughput. Poor UX (gas, delayed PoW finality). No sovereignty (shared throughput/clogging risk, tech stack not customizable, governance dependence)." "Many projects are exploring Ethereum-compatible blockchains as a way to mitigate these limitations while still leveraging Ethereum’s thriving ecosystem."

"A blockchain bridge is a way to connect two distinct blockchains and enable communication between them. Polygon offers a trustless, two-way transaction channel between Polygon and Ethereum. It introduced the cross-chain bridge with Plasma and Proof of Stake (PoS) security." “A bridge is basically a set of contracts that help in moving assets from the root chain to the child chain. There are primarily two bridges to move assets between Ethereum and Polygon.”

"(1) User deposits tokens to a Polygon contract on the Root Chain (Ethereum). (2) When the token deposit transaction is confirmed on Ethereum, corresponding tokens will be minted on the Polygon chain. These tokens are ready to be used on the Polygon network. (3) When a user is ready to withdraw from the Child Chain (Polygon), they can do so by initiation from Polygon. A checkpoint interval needs to pass (around 30 minutes) where all blocks have been validated since the last checkpoint. Checkpoint is then submitted to the Root Chain contract. (4) An EXIT NFT token is minted of the value the user wants to withdraw. (5) A wait period is initialized, and the user needs to wait for seven days before being able to withdraw their funds. (6) Using the process-exit procedure, once the waiting period finishes, a user can claim back funds to their Ethereum account."

"Whitehat Gerhard Wagner submitted a critical vulnerability on October 5th, 2021 that affected the Polygon Plasma Bridge. The vulnerability allowed an attacker to exit their burn transaction from the bridge multiple times, up to 223 times. There was around ~$850M at risk. Having just $100k to launch the attack with would result in $22.3M in losses! This means the DepositManager for the Plasma Bridge could be depleted with a sufficient amount."

"The main vulnerability lies in how Polygon’s WithdrawManager verifies the inclusion and uniqueness of the burn transaction in previous blocks." "One crucial parameter the exit proof contains is Merkle proof’s branchMask for the receipt. branchMask is an essential security guard that helps keep the system secure. That’s why the branch mask must be unique, as it is used to generate Exit ID. Property that needs to be behold is one exiting transaction == one Exit ID. But as the whitehat found, that’s not necessarily the case."

"An important security property that must always hold when a user starts an exit is that one exit id can only refer to one burn transaction. The exit id is composed partly of the branch mask that comes directly from user input, which immediately felt like a soft spot when I looked at the code for the first time. If it were possible to create an alternative branch mask that somehow passes the receipt inclusion proof, then we would find a way to create more than one exit id referring to the same burn transaction."

"Because the decoding into an array of nibbles ignores some of the value and differences in the ignored portion are not rejected by the uint256 decoding, the same value as decoded by MerklePatriciaProof may have many encodings as a uint256. The uint256 decoding is the one used to avoid replays; therefore the same proof can be replayed due to the differences in the decoding." "The same valid transaction can be resubmitted up to 223 times with different values for the first byte of the HP-encoded path."

"There are capital requirements for a successful attack, but they are minimal compared to a malicious user’s potential reward." "Having just $100k to launch the attack with would result in $22.3M in losses!"

"The Immunefi triaging team confirmed the underlying issue and escalated it to the client. After 30 minutes, Polygon confirmed the bug and immediately began fixing the underlying issue. In the meantime, the triage team decided to calculate the funds at risk. The whitehat also confirmed our calculations, and Polygon agreed to pay the maximum for this submission."

"As it turns out, the first byte of the encoded branch mask is supposed to always be 0x00. The fix is to check if the first byte of the encoded branch mask is 0x00 and not to disregard it as an incorrect mask."

"Polygon fixed [the] critical double spend vulnerability in the Plasma Bridge after it was responsibly disclosed by Gerhard Wagner. The whitehat collected a cool $2M bounty thanks to the bug bounty program hosted by Immunefi."

"The whitehat received a payout of $2m from Polygon, which is the highest bounty ever paid out in history. We congratulate Gerhard for his fantastic work and excellent report. We also want to thank Polygon for a swift answer and subsequent fix."

This is a global/international case not involving a specific country.

The background of the exchange platform, service, or individuals involved, as it would have been seen or understood at the time of the events.

Include:

  • Known history of when and how the service was started.
  • What problems does the company or service claim to solve?
  • What marketing materials were used by the firm or business?
  • Audits performed, and excerpts that may have been included.
  • Business registration documents shown (fake or legitimate).
  • How were people recruited to participate?
  • Public warnings and announcements prior to the event.

Don't Include:

  • Any wording which directly states or implies that the business is/was illegitimate, or that a vulnerability existed.
  • Anything that wasn't reasonably knowable at the time of the event.

There could be more than one section here. If the same platform is involved with multiple incidents, then it can be linked to a main article page.

The Reality

This sections is included if a case involved deception or information that was unknown at the time. Examples include:

  • When the service was actually started (if different than the "official story").
  • Who actually ran a service and their own personal history.
  • How the service was structured behind the scenes. (For example, there was no "trading bot".)
  • Details of what audits reported and how vulnerabilities were missed during auditing.

What Happened

The specific events of the loss and how it came about. What actually happened to cause the loss and some of the events leading up to it.

Key Event Timeline - Polygon Double Spend Vulnerability
Date Event Description
October 5th, 2021 Main Event Expand this into a brief description of what happened and the impact. If multiple lines are necessary, add them here.

Technical Details

This section includes specific detailed technical analysis of any security breaches which happened. What specific software vulnerabilities contributed to the problem and how were they exploited?

Total Amount Lost

The total amount at risk has been estimated at $850,000,000 USD. No funds were lost.

How much was lost and how was it calculated? If there are conflicting reports, which are accurate and where does the discrepancy lie?

Immediate Reactions

How did the various parties involved (firm, platform, management, and/or affected individual(s)) deal with the events? Were services shut down? Were announcements made? Were groups formed?

Ultimate Outcome

What was the end result? Was any investigation done? Were any individuals prosecuted? Was there a lawsuit? Was any tracing done?

A bounty of $2,000,000 USD was paid for the discovery.

Total Amount Recovered

There do not appear to have been any funds recovered in this case.

What funds were recovered? What funds were reimbursed for those affected users?

Ongoing Developments

What parts of this case are still remaining to be concluded?

Individual Prevention Policies

No specific policies for individual prevention have yet been identified in this case.

For the full list of how to protect your funds as an individual, check our Prevention Policies for Individuals guide.

Platform Prevention Policies

Policies for platforms to take to prevent this situation have not yet been selected in this case.

For the full list of how to protect your funds as a financial service, check our Prevention Policies for Platforms guide.

Regulatory Prevention Policies

No specific regulatory policies have yet been identified in this case.

For the full list of regulatory policies that can prevent loss, check our Prevention Policies for Regulators guide.

References