0x Invalid Signature Flaw: Difference between revisions
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
{{Imported Case Study|source=https://www.quadrigainitiative.com/casestudy/0xinvalidsignatureflaw.php}} | {{Imported Case Study 2|source=https://www.quadrigainitiative.com/casestudy/0xinvalidsignatureflaw.php}} | ||
{{Unattributed | {{Unattributed Sources}} | ||
[[File:0xproject.jpg|thumb|0x Project]]The 0x project offered a "liquidity aggregator" which is used as part of an online exchange. In order to use the exchange, a trader needs to sign the transaction. However, there was a way to bypass this mechanism, which could have allowed an attacker to conduct fraudulent trades. | [[File:0xproject.jpg|thumb|0x Project]]The 0x project offered a "liquidity aggregator" which is used as part of an online exchange. In order to use the exchange, a trader needs to sign the transaction. However, there was a way to bypass this mechanism, which could have allowed an attacker to conduct fraudulent trades. | ||
| Line 6: | Line 6: | ||
The exploit was fixed before any funds were taken. | The exploit was fixed before any funds were taken. | ||
This is a global/international case not involving a specific country. | This is a global/international case not involving a specific country.<ref name="openzeppelinforum-1155" /><ref name="0xprojectblog-2033" /><ref name="0xprojectmedium-2034" /><ref name="samczsun-2035" /><ref name="consensysdiligencemedium-2036" /><ref name="0x-2037" /><ref name="consensysgithub-2038" /> | ||
<ref name="openzeppelinforum-1155" /><ref name="0xprojectblog-2033" /><ref name="0xprojectmedium-2034" /><ref name="samczsun-2035" /><ref name="consensysdiligencemedium-2036" /><ref name="0x-2037" /><ref name="consensysgithub-2038" /> | |||
== About 0x Project == | == About 0x Project == | ||
| Line 71: | Line 70: | ||
!Description | !Description | ||
|- | |- | ||
|July 13th, 2019 | |July 13th, 2019 | ||
|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 79: | Line 78: | ||
| | | | ||
|} | |} | ||
== 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 98: | Line 100: | ||
== 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? | ||
== General Prevention Policies == | |||
There was no loss to users of the exchange in this case. | |||
== 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:Regulators:End}} | |||
== References == | == References == | ||
<references><ref name="openzeppelinforum-1155">[https://forum.openzeppelin.com/t/list-of-ethereum-smart-contracts-post-mortems/1191 List of Ethereum Smart Contracts Post-Mortems - Security - OpenZeppelin Community] (Jun | <references><ref name="openzeppelinforum-1155">[https://forum.openzeppelin.com/t/list-of-ethereum-smart-contracts-post-mortems/1191 List of Ethereum Smart Contracts Post-Mortems - Security - OpenZeppelin Community] (Jun 23, 2021)</ref> | ||
<ref name="0xprojectblog-2033">[https://blog.0xproject.com/shut-down-of-0x-exchange-v2-0-contract-and-migration-to-patched-version-6185097a1f39 Shut down of 0x Exchange v2.0 contract and migration to patched version | by Will Warren | 0x Blog] (Jun | <ref name="0xprojectblog-2033">[https://blog.0xproject.com/shut-down-of-0x-exchange-v2-0-contract-and-migration-to-patched-version-6185097a1f39 Shut down of 0x Exchange v2.0 contract and migration to patched version | by Will Warren | 0x Blog] (Jun 23, 2021)</ref> | ||
<ref name="0xprojectmedium-2034">[https://medium.com/0x-project/post-mortem-0x-v2-0-exchange-vulnerability-763015399578 Post Mortem 0x V2 0 Exchange Vulnerability] (Jun | <ref name="0xprojectmedium-2034">[https://medium.com/0x-project/post-mortem-0x-v2-0-exchange-vulnerability-763015399578 Post Mortem 0x V2 0 Exchange Vulnerability] (Jun 23, 2021)</ref> | ||
<ref name="samczsun-2035">[https://samczsun.com/the-0x-vulnerability-explained/ The 0x vulnerability, explained] (Jun | <ref name="samczsun-2035">[https://samczsun.com/the-0x-vulnerability-explained/ The 0x vulnerability, explained] (Jun 23, 2021)</ref> | ||
<ref name="consensysdiligencemedium-2036">[https://medium.com/consensys-diligence/return-data-length-validation-a-bug-we-missed-4b7bbea8e9ab#ec12-515fdbeed4d5 Return Data Length Validation A Bug We Missed] (Jun | <ref name="consensysdiligencemedium-2036">[https://medium.com/consensys-diligence/return-data-length-validation-a-bug-we-missed-4b7bbea8e9ab#ec12-515fdbeed4d5 Return Data Length Validation A Bug We Missed] (Jun 23, 2021)</ref> | ||
<ref name="0x-2037">[https://0x.org/ 0x: Powering the decentralized exchange of tokens on Ethereum] (Jun | <ref name="0x-2037">[https://0x.org/ 0x: Powering the decentralized exchange of tokens on Ethereum] (Jun 24, 2021)</ref> | ||
<ref name="consensysgithub-2038">[https://github.com/ConsenSys/0x_audit_report_2018-07-23 GitHub - ConsenSys/0x_audit_report_2018-07-23: 0x Protocol v2 Audit] (Jun | <ref name="consensysgithub-2038">[https://github.com/ConsenSys/0x_audit_report_2018-07-23 GitHub - ConsenSys/0x_audit_report_2018-07-23: 0x Protocol v2 Audit] (Jun 24, 2021)</ref></references> | ||
Latest revision as of 13:22, 1 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' and 'General Prevention' sections 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!
The 0x project offered a "liquidity aggregator" which is used as part of an online exchange. In order to use the exchange, a trader needs to sign the transaction. However, there was a way to bypass this mechanism, which could have allowed an attacker to conduct fraudulent trades.
The exploit was fixed before any funds were taken.
This is a global/international case not involving a specific country.[1][2][3][4][5][6][7]
About 0x Project
The "0x API is a professional grade liquidity aggregator, enabling the future of DeFi applications." Their "smart order routing splits up your transaction across decentralized exchange networks to be filled with the lowest slippage possible."
"From July 23, 2018 to September 7, 2018 ConsenSys Diligence conducted a security audit of the 0x project's protocol version v2 of their contract system."
"On Friday July 12th, 0x shut down their v2 Exchange because a flaw in the signature verification routine meant that a signature of 0x04 was treated as a valid signature for all non-smart-contract accounts."
"Under normal circumstances (a conformant IFetcher implementation), this code works fine, but something surprising happens if you pass in an externally owned account (EOA). An EOA address has no associated code, and this means all calls to it succeed and return nothing. The low-level STATICCALL opcode used here will return success but will only copy as much data into memory as was returned. So even though we asked for 32 bytes of return data, nothing gets copied to memory because there is no data to copy."
"Because nothing gets copied, memory is just as it was before the call. That means ptr is still pointing to the selector data, so this function returns 0xa95c372d000000… (the function selector for fetch())."
"The same thing happens if you call a contract that implements fetch() without a return value or just implements a fallback function. The bug occurs any time the call succeeds but doesn’t return as much data as the caller expects."
"This bug manifested itself in the 0x v2.0 Exchange in a particularly nasty way due to where the bug was. The exchange allows trades to be constructed off chain and then validated and filled on chain. To know that a trade is authorized, the exchange must validate a trader’s signature."
"One option the exchange offers for validating a trader’s signature is to delegate that checking to a contract. Essentially, the trader can be a smart wallet that implements a function with the signature isValidSignature(bytes32,bytes) and returns a boolean true if the signature is valid."
"[T]he problem is that isValidSignature is called via code that’s very similar to the above vulnerable contract. If the target is not a smart contract (or otherwise returns no data), the data already in memory stays unchanged. Any non-zero value there is interpreted as true and authorizes the trade."
"Even this would be okay if traders had to specifically opt in to this type of signature scheme, but remember that these trades are constructed off chain to avoid the expense and delay of making an on chain transaction. So the person taking the proposed trade is able to dictate which type of signature checking should happen via a flag."
"All an attacker needs to do is trade with an externally owned account and specify that the signature should be checked by calling isValidSignature. This validation will succeed because no data is returned and the data already present in memory is non-zero."
The project "patched and re-deployed the[ir] entire 0x smart contract pipeline from scratch, updated [their] developer tools and packages, 0x Instant, and 0x Launch Kit." "[T]he vulnerability found in the 0x v2.0 Exchange contract was not exploited and no user funds [were] lost."
"Teams will need to point to the patched and newly deployed Exchange and AssetProxy contracts as well as clear their orderbooks of outstanding orders. Users will need to reset their allowances for the new 0x AssetProxy contracts."
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.
| Date | Event | Description |
|---|---|---|
| July 13th, 2019 | 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
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?
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?
General Prevention Policies
There was no loss to users of the exchange in this case.
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
- ↑ List of Ethereum Smart Contracts Post-Mortems - Security - OpenZeppelin Community (Jun 23, 2021)
- ↑ Shut down of 0x Exchange v2.0 contract and migration to patched version | by Will Warren | 0x Blog (Jun 23, 2021)
- ↑ Post Mortem 0x V2 0 Exchange Vulnerability (Jun 23, 2021)
- ↑ The 0x vulnerability, explained (Jun 23, 2021)
- ↑ Return Data Length Validation A Bug We Missed (Jun 23, 2021)
- ↑ 0x: Powering the decentralized exchange of tokens on Ethereum (Jun 24, 2021)
- ↑ GitHub - ConsenSys/0x_audit_report_2018-07-23: 0x Protocol v2 Audit (Jun 24, 2021)