<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ABA]]></title><description><![CDATA[Unearthing Vulnerabilities; Forging Secure Code]]></description><link>https://abarbatei.xyz</link><image><url>https://cdn.hashnode.com/res/hashnode/image/upload/v1697200509004/KUL3D1VuS.jfif</url><title>ABA</title><link>https://abarbatei.xyz</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 22:16:09 GMT</lastBuildDate><atom:link href="https://abarbatei.xyz/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Reviewing Issues with DN404 Code]]></title><description><![CDATA[From the 23rd of April and up to the 3rd of May 2024 Guardian Audits was engaged in a security review of the DN404🥜 codebase. Five people were on the audit, myself included.
A lot of interesting findings were discovered, interesting enough to be put...]]></description><link>https://abarbatei.xyz/reviewing-dn404</link><guid isPermaLink="true">https://abarbatei.xyz/reviewing-dn404</guid><category><![CDATA[DN404]]></category><category><![CDATA[Cryptocurrency]]></category><category><![CDATA[Smart Contracts]]></category><category><![CDATA[smart contract security audit]]></category><category><![CDATA[NFT]]></category><category><![CDATA[erc404]]></category><category><![CDATA[ERC-404]]></category><dc:creator><![CDATA[ABA]]></dc:creator><pubDate>Wed, 05 Jun 2024 23:35:11 GMT</pubDate><content:encoded><![CDATA[<p>From the 23rd of April and up to the 3rd of May 2024 <a target="_blank" href="https://guardianaudits.com">Guardian Audits</a> was engaged in a security review of the <a target="_blank" href="https://github.com/Vectorized/dn404">DN404🥜</a> codebase. Five people were on the audit, myself included.</p>
<p>A lot of interesting findings were discovered, interesting enough to be put into writing.
You can find these findings (pun intended) in the article: <a target="_blank" href="https://guardianaudits.com/blog/dn404-vulnerabilities-reported-and-resolved">DN404 - Vulnerabilities Reported And Resolved</a>.</p>
<p><img src="https://d1pnnwteuly8z3.cloudfront.net/images/f70168b2-a3ba-411c-9dd5-9ccf228d3067/e4813c31-b4e3-4e62-a7df-0e480c225a2c.png" alt="Guardian Audits" /></p>
<p>As a side-note, the name "DN" <em>definitely</em> did not originally come from the internet "DeezNuts" phenomenon, later being associated with more formal names that coincidentally match, such as "Divisible NFT" or "Dual Nature".</p>
]]></content:encoded></item><item><title><![CDATA[Blockchain reorgs for Managers and Auditors]]></title><description><![CDATA[Executive overview

There exists a blockchain event referred to as blockchain reorganization or reorgs. When this event happens, transactions can be discarded or reordered within a block and this can span across multiple blocks

Depending on the Web3...]]></description><link>https://abarbatei.xyz/blockchain-reorgs-for-managers-and-auditors</link><guid isPermaLink="true">https://abarbatei.xyz/blockchain-reorgs-for-managers-and-auditors</guid><category><![CDATA[reorg]]></category><category><![CDATA[Blockchain]]></category><category><![CDATA[Web3]]></category><category><![CDATA[smart contract auditors]]></category><category><![CDATA[management]]></category><dc:creator><![CDATA[ABA]]></dc:creator><pubDate>Mon, 18 Mar 2024 14:44:55 GMT</pubDate><content:encoded><![CDATA[<h1 id="heading-executive-overview">Executive overview</h1>
<ul>
<li><p>There exists a blockchain event referred to as blockchain reorganization or reorgs. When this event happens, transactions can be discarded or reordered within a block and this can span across multiple blocks</p>
</li>
<li><p>Depending on the Web3 product type being built, reorgs can be a natural issue that needs to be taken into consideration. See <a target="_blank" href="https://abarbatei.xyz/blockchain-reorgs-for-managers-and-auditors#heading-products-susceptible-to-blockchain-reorgs"><strong><em>Products susceptible to blockchain reorgs</em></strong></a> for more information</p>
</li>
<li><p>Depending on the blockchain, these events are more or less frequent. In some extreme cases a reorg has affected as much as 5 minutes of history. See <a target="_blank" href="https://abarbatei.xyz/blockchain-reorgs-for-managers-and-auditors#heading-metrics-for-protocols-and-auditors"><strong><em>Metrics for protocols and auditors</em></strong></a> for more information</p>
</li>
<li><p>A coordinated malicious attack can also cause a blockchain reorg. Although improbable it has happened in the past leading to a double spending attack</p>
</li>
<li><p>For <strong><em>auditors</em></strong>, there are examples provided of issues for each product type</p>
</li>
</ul>
<h1 id="heading-detailed-overview">Detailed overview</h1>
<p>In Web3 we often hear the idiom <em>the blockchain is immutable</em> but there are cases when it's not, or to be more precise it becomes <em>practically</em> immutable (reach finality) only after some time has passed since the block, which contains users' transactions, was minted. This is due to events called blockchain reorganizations, or <strong>reorgs</strong> for short.</p>
<p>Paradigm has one of the <a target="_blank" href="https://www.paradigm.xyz/2021/07/ethereum-reorgs-after-the-merge">best articles on reorgs</a>, how and why it happens. I highly recommend you give it a read as we will only briefly touch on why it fundamentally happens. From the mentioned article, we have the following good block reorg definition:</p>
<blockquote>
<p>A <strong>reorg</strong> is an event where a block that was part of the canonical chain becomes no longer part of the canonical chain because a competing block beat it out.</p>
</blockquote>
<p>Reorgs happen because of the way blockchain validation client softer works. The algorithm that determines which is the canonical chain (fork choice rule), under certain circumstances, can conclude that the current chain history is not optimal and choose a different chain from those provided by competing miners (fork chains), to become the canonical chain.</p>
<p><em>When a block reorg happens, as an external observer of the chain you see that:</em></p>
<ul>
<li><p><em>several blocks have been discarded and replaced with others</em></p>
</li>
<li><p><em>this does not imply that all transactions in the original blocks were discarded, a large number will probably still be included in the new blocks, possibly even all but not in the same order</em></p>
</li>
</ul>
<p>Reorgs appear more often than people realize. Using on-chain explorers such as <a target="_blank" href="https://polygonscan.com/blocks_forked">polygonscan.com/blocks_forked</a>, for Polygon reorgs, you can see they appear often:</p>
<p><img src="https://res.cloudinary.com/duhkspn7a/image/upload/v1697204594/reorgs_lc1ytb.png" alt="polygonscan blocks forked" /></p>
<p>The first reorg in the image indicates a <code>ReorgDepth</code> of 11, meaning 11 blocks were discarded (approx. 22 seconds of history was changed).</p>
<h1 id="heading-products-susceptible-to-blockchain-reorgs">Products susceptible to blockchain reorgs</h1>
<p>Protocols or systems that are naturally vulnerable to blockchains reorgs are:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Products vulnerable to reorgs</td><td>Examples and details</td></tr>
</thead>
<tbody>
<tr>
<td><strong>On-chain random based systems</strong></td><td>Examples: <br />- betting protocols <br />- on-chain casinos <br />- random reward systems</td></tr>
<tr>
<td><strong>Off-ramp crypto systems</strong></td><td>Examples: <br />- centralized exchanges (CEX) <br />- crypto-to-fiat providers</td></tr>
<tr>
<td><strong>Protocols that require users to create something and then interact with it in a two step manner</strong></td><td>- yes, this is vague <br />- the majority of problematic systems here are those that have user deploy a contract then interact with it<br /><br />Example behavior to look for:  <br />- deploying a vault in one transaction and depositing funds to it in another  <br />- user creates a proposal then votes on it in an on-chain voting system</td></tr>
<tr>
<td><strong>Cross-chain mechanisms</strong></td><td>- yes, this is also vague <br /><br />Examples:  <br />- cross-chain communication protocols  <br />- token bridges  <br />- cross-chain  gas acquisition mechanisms</td></tr>
<tr>
<td><strong>Systems where an on-chain action has a gradual effect depending on its proximity to a specific block or timestamp</strong></td><td>Examples:  <br />- on-chain Dutch auctions</td></tr>
<tr>
<td><strong>Blockchain validation software</strong></td><td>Example:  <br />- node validation clients</td></tr>
</tbody>
</table>
</div><h1 id="heading-metrics-for-protocols-and-auditors">Metrics for protocols and auditors</h1>
<p>When designing or auditing a protocol that may be vulnerable to reorg issues there are some data points that must be taken into account which are particular to each chain. The following table serves as a reference point.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Blockchain</td><td>Reorgs/day</td><td>Max depth/day</td><td>Largest known reorg</td><td>Average block time (approx. in seconds)</td></tr>
</thead>
<tbody>
<tr>
<td>Ethereum</td><td>10-25</td><td>1</td><td>1</td><td>12.08</td></tr>
<tr>
<td>Cronos</td><td>10+</td><td>5-7</td><td>7</td><td>5.6</td></tr>
<tr>
<td>Polygon PoS</td><td>2-10</td><td>5-15</td><td>157</td><td>2.2</td></tr>
<tr>
<td>BNB Chain</td><td>0-2</td><td>1</td><td>5</td><td>3</td></tr>
<tr>
<td>Avalanche C-Chain</td><td>reorgs not possible</td><td>reorgs not possible</td><td>reorgs not possible</td><td>2</td></tr>
<tr>
<td>Fantom</td><td>reorgs not possible</td><td>reorgs not possible</td><td>reorgs not possible</td><td>1.41</td></tr>
<tr>
<td>Arbitrum One</td><td>0</td><td>0</td><td>0</td><td>0.25</td></tr>
<tr>
<td>Optimism</td><td>0</td><td>0</td><td>0</td><td>2</td></tr>
<tr>
<td>Base</td><td>0</td><td>0</td><td>0</td><td>2</td></tr>
<tr>
<td>zkSync Era</td><td>0</td><td>0</td><td>0</td><td>2</td></tr>
</tbody>
</table>
</div><p>Notes and observations</p>
<ul>
<li><p>the above data has been collected either from 3rd party aggregators or from sites displaying the raw data directly. They are also taken after any major changes in the network, e.g. for Ethereum after PoS and for BNB Chain after their latest major scalability changes that drastically reduced reorg rates</p>
</li>
<li><p>When deciding how much blocks to wait before confirming a transaction off-chain in sensitive systems (such as crypto to fiat off-ramps) it is best to wait a number of blocks more then highest know reorg depth on that chain that happened historically</p>
<ul>
<li>For example, deposits on a CEX from Polygon can wait even 200 blocks before being regarded as final</li>
</ul>
</li>
<li><p>L2s theoretically can experience reorgs but it has never happened in practice (at least not know to or found out by the author of this article).</p>
</li>
<li><p>In the <strong><em>References</em></strong> section you can find links from where the above numbers were collected</p>
</li>
</ul>
<h1 id="heading-product-detailed-reorg-issues-explained">Product detailed reorg issues explained</h1>
<p>For each of the aforementioned type of products or system susceptible to blockchain reorg issues that were mentioned, a detailed description follows.</p>
<h2 id="heading-on-chain-random-based-systems"><strong>On-chain random based systems</strong></h2>
<p>On-chain protocols that have a random component are naturally affected by blockchain reorgs. These type of protocols can be betting, casino types, games with a random reward system, practically <em>anything that calculates randomness using an oracle.</em></p>
<p>Example of situations that can appear:</p>
<ul>
<li><p>a player wins a good reward in random draw but due to a blockchain reorg he loses it</p>
</li>
<li><p>a gambler loses an on-chain dice game but due to a blockchain reorg he now actually wins</p>
</li>
</ul>
<p>In practice, <a target="_blank" href="https://docs.chain.link/vrf/v2/security/#choose-a-safe-block-confirmation-time-which-will-vary-between-blockchains">Chainlink's VRF</a> (Verifiable Random Function) is often used to calculate random number. This API accepts a block confirmation time, which, to quote the documentation represents:</p>
<blockquote>
<p>how many blocks the VRF service waits before writing a fulfillment to the chain to make potential rewrite attacks unprofitable in the context of your application and its value-at-risk.</p>
</blockquote>
<p>Examples of this type of vulnerability seen in audits:</p>
<ul>
<li><p><code>07/10/2021</code><a target="_blank" href="https://solodit.xyz/issues/h-02-miners-can-re-roll-the-vrf-output-to-game-the-protocol-code4rena-pooltogether-pooltogether-git"><strong>Miners Can Re-Roll the VRF Output to Game the Protocol</strong></a></p>
</li>
<li><p><code>01/06/2023</code><a target="_blank" href="https://solodit.xyz/issues/c-01-polygon-chain-reorgs-will-often-change-game-results-pashov-none-nft-loots-markdown"><strong>Polygon chain reorgs will often change game results</strong></a></p>
</li>
<li><p><code>20/11/2023</code><a target="_blank" href="https://solodit.xyz/issues/polygon-chain-reorgs-will-change-mystery-box-tiers-which-can-be-gamed-by-validators-cyfrin-none-cyfrin-mode-earnm-markdown"><strong>Polygon chain reorgs will change mystery box tiers which can be gamed by validators</strong></a></p>
</li>
</ul>
<p>To mitigate this issue, it is enough to choose an appropriate block confirmation time. See <strong><em>Metrics for protocols and auditors</em></strong> for recommended numbers.</p>
<h2 id="heading-off-ramp-systems"><strong>Off-ramp systems</strong></h2>
<p>To off-ramp crypto, refers to <strong>the process of exchanging cryptocurrencies for fiat currency</strong>. Systems doing crypto off-ramping include:</p>
<ul>
<li><p>centralized exchanges (CEX)</p>
</li>
<li><p>crypto-to-fiat providers</p>
</li>
</ul>
<p>Crypto deposits into these systems are confirmed after a specific number of blocks have passed since the transaction in order to mitigate any issues possibly caused by blockchain reorgs.</p>
<p><a target="_blank" href="https://cryptohead.io/how-many-confirmations-for-ethereum/">This article</a> gives some specific block confirmations requirements found on know CEXs. Example Coinbase requires 35 block confirmations for ETH deposits while Binance requires only 12.</p>
<p><em>As an observation, CEXs tend to severely over-wait for confirmations. Example, a blockchain reorg on Ethereum of more then 2 blocks has not happened in years.</em></p>
<p>Off-ramp systems, particularly CEXs, are an attractive target for <a target="_blank" href="https://www.investopedia.com/terms/1/51-attack.asp">51% attacks</a>. In the past, there were several cases where attackers gained 51% of a network validation resources (hashing rate) and proceed to initiate withdrawals on several exchanges then reorg the chain in order to re-initiate the withdrawals on other exchanges.</p>
<p>Most notable 51% attacks are mentioned in <a target="_blank" href="https://cryptoslate.com/prolific-51-attacks-crypto-verge-ethereum-classic-bitcoin-gold-feathercoin-vertcoin/">this article</a> and involve the Verge, Ethereum Classic, Bitcoin Gold, Feathercoin and Vertcoin tokens.</p>
<p>Mitigating this form of attack is not straight forward. One component of the solution is to overly increase the required confirmation count. Although in those cases this is not enough, as the network takeover can last an undefined amount of time. An on-chain monitoring solution coupled with withdrawals/deposits pausing need to implemented.</p>
<h2 id="heading-protocols-that-require-users-to-create-something-and-then-interact-with-it-in-a-two-step-manner"><strong>Protocols that require users to create something and then interact with it in a two step manner</strong></h2>
<p>(yes, the title is too big)</p>
<p>This type of reorg issues are the most frequently seen in this vulnerability category. They appear when a protocol requires users to first create or initiate a component and then, in a different transaction to interact with it.</p>
<p>Another important and key precondition is that the deployed contracts use the Solidity <a target="_blank" href="https://docs.soliditylang.org/en/v0.8.25/control-structures.html#creating-contracts-via-new">new</a> keyword for contract creation (or the <a target="_blank" href="https://docs.soliditylang.org/en/v0.8.25/yul.html#evm-dialect"><strong>CREATE opcode</strong></a><strong>).</strong> Both of these rely on the calling contract nonce to determine the address of the newly-deployed contract and do not take into consideration any custom input.</p>
<p>Example, a protocol uses a factory-like pattern to deploy contracts, whos functions are permissionless. Say the factory logic deploys a contract via one call while giving special permissions to the deployer. After the deploy, the user send a deposit to the newly deployed contract.</p>
<p>An example attack scenario in the above case:</p>
<ul>
<li><p><code>alice</code> creates a vault via the factory contract (transaction A)</p>
</li>
<li><p><code>alice</code> then deposits into the vault tokens (transaction B)</p>
</li>
<li><p>a block reorg happens and transaction A is discarded (transaction B still exists)</p>
</li>
<li><p>normally transaction B now would revert if executed</p>
</li>
<li><p><code>bob</code> deploys himself the vault that initially <code>alice</code> did (via frontrunning) and because of the underlying issue, it is created on the same address as the initial vault</p>
</li>
<li><p><code>alice</code>'s deposit reaches now <code>bob</code>'s vault, and he can withdraw it</p>
</li>
</ul>
<p>Another interesting example seen ITAW (In The Audit Wilderness) is:</p>
<ul>
<li><p><code>alice</code> creates a proposal; proposal ID is determined by a counter increment only (transaction A)</p>
</li>
<li><p><code>alice</code> votes on her proposal (transaction B)</p>
</li>
<li><p>a block reorg happens and transaction A is discarded (transaction B still exists)</p>
</li>
<li><p>normally transaction B now would revert if executed</p>
</li>
<li><p><code>bob</code> creates himself a different proposal (via frontrunning) which receives the same ID as <code>alice</code>'s due to faulty implementation</p>
</li>
<li><p><code>alice</code>'s vote now reaches a malicious proposal</p>
</li>
</ul>
<p>Examples of this type of vulnerability seen in audits:</p>
<ul>
<li><p><code>25/01/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-01-questfactory-is-suspicious-of-the-reorg-attack-code4rena-rabbithole-rabbithole-quest-protocol-contest-git"><strong>QuestFactory is suspicious of the reorg attack</strong></a></p>
</li>
<li><p><code>12/04/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-14-re-org-attack-in-factory-code4rena-frankencoin-frankencoin-git"><strong>Re-org attack in factory</strong></a></p>
</li>
<li><p><code>23/05/2023</code><a target="_blank" href="https://solodit.xyz/issues/trst-m-3-attacker-could-abuse-victims-vote-to-pass-their-own-proposal-trust-security-none-mozaic-archimedes-markdown_"><strong>Attacker could abuse victim's vote to pass their own proposal</strong></a></p>
</li>
<li><p><code>30/05/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-04-many-create-methods-are-suspicious-of-the-reorg-attack-code4rena-maia-dao-ecosystem-maia-dao-ecosystem-git"><strong>Many</strong><code>create</code><strong>methods are suspicious of the reorg attack</strong></a></p>
</li>
<li><p><code>07/07/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-08-an-attacker-can-front-run-deployvault-to-deploy-at-the-same-address-code4rena-pooltogether-pooltogether-git"><strong>An attacker can front-run</strong><code>deployVault</code><strong>to deploy at the same address</strong></a></p>
</li>
<li><p><code>17/07/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-01-identifying-publications-using-its-id-makes-the-protocol-vulnerable-to-blockchain-re-orgs-code4rena-lens-protocol-lens-protocol-git"><strong>Identifying publications using its ID makes the protocol vulnerable to blockchain re-orgs</strong></a></p>
</li>
<li><p><code>02/08/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-09-create-methods-are-suspicious-of-the-reorg-attack-code4rena-pooltogether-pooltogether-git"><strong>Create methods are suspicious of the reorg attack</strong></a></p>
</li>
</ul>
<p>To mitigate the issue use the <a target="_blank" href="https://docs.soliditylang.org/en/v0.8.25/control-structures.html#salted-contract-creations-create2">create2 opcode</a> and have the salt contain elements distinctive of the caller (e.g. hash on the inputs plus the <code>msg.sender</code>).</p>
<h2 id="heading-cross-chain-mechanisms"><strong>Cross-chain mechanisms</strong></h2>
<p>Similar to how CEXs or crypto off-ramp solutions need to consider block reorganizations so does any cross-chain mechanism that needs an off-chain component to transfer data from one chain to another.</p>
<p>Issues can appear if one of the destination or source chain reorgs which may create situations where a bridging was removed on the source chain but on the destination chain it was created. Leading to double spending.</p>
<p>Examples:</p>
<ul>
<li><p>cross-chain communication protocols</p>
</li>
<li><p>token bridges</p>
</li>
<li><p>cross-chain gas acquisition mechanisms (e.g. <a target="_blank" href="https://www.gasbot.xyz/">gasbot</a>)</p>
</li>
</ul>
<p>Examples of this type of vulnerability seen in audits:</p>
<ul>
<li><p><code>09/05/2023</code><a target="_blank" href="https://solodit.xyz/issues/block-reorg-can-allow-for-double-spending-auditone-none-aurorafastbridge-markdown"><strong>Block Reorg Can Allow For Double Spending</strong></a></p>
</li>
<li><p><code>07/01/2024</code><a target="_blank" href="https://github.com/GasBot-xyz/gasbot_audit/blob/main/audit/202401_KrisApostolov_GasbotV2.pdf">Polygon re-orgs can cause the protocol to lose funds</a></p>
</li>
</ul>
<p>Mitigation is again straightforward and involves waiting a specific amount of blocks before considering a transaction as done (finalized). See <strong><em>Metrics for protocols and auditors</em></strong> for exact numbers</p>
<h2 id="heading-systems-where-an-on-chain-action-has-a-gradual-effect-depending-on-its-proximity-to-a-specific-block-or-timestamp"><strong>Systems where an on-chain action has a gradual effect depending on its proximity to a specific block or timestamp</strong></h2>
<p>(yes, this is another title that is too big)</p>
<p>There are protocols for which the result of an on-chain action depend <em>gradually</em> on their proximity to a specific block number or timestamp. There are, by their nature vulnerable to reorgs since transactions can be shuffled within a reorg leading to different outcome then expected.</p>
<p>The predominant (only) example see in this case is that of a <a target="_blank" href="https://www.investopedia.com/terms/d/dutchauction.asp">Dutch auction</a>:</p>
<ul>
<li><p><code>alice</code> initiates a payment at <code>auctionStartBlock + 3</code> needing to pay <code>price/3</code></p>
</li>
<li><p>a block reorg happens and <code>alice</code>'s transaction is now put at <code>auctionStartBlock + 2</code></p>
</li>
<li><p>the transaction goes through and <code>alice</code> ends up paying <code>price/2</code></p>
</li>
</ul>
<p>Examples of this type of vulnerability seen in audits:</p>
<ul>
<li><p><code>25/03/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-2-useloan-doesnt-allow-liqudator-to-specifiy-maximum-price-sherlock-kairos-kairos-loan-git"><strong>useLoan doesn't allow liqudator to specifiy maximum price</strong></a></p>
</li>
<li><p><code>11/12/2023</code><a target="_blank" href="https://solodit.xyz/issues/m-01-no-check-for-sequencer-uptime-can-lead-to-dutch-auctions-failing-or-executing-at-bad-prices-code4rena-ethereum-credit-guild-ethereum-credit-guild-git"><strong>No check for sequencer uptime can lead to dutch auctions failing or executing at bad prices</strong></a></p>
</li>
</ul>
<p>The issue is mitigated per project value logic. In the Dutch auction example, a maximum payable amount should also be passed as a parameter when initiating the buy.</p>
<h2 id="heading-blockchain-validation-software"><strong>Blockchain validation software</strong></h2>
<p>There are over <a target="_blank" href="https://moralis.io/how-many-blockchains-are-there-and-what-are-the-different-types/">1000 different</a> blockchains in existence, each with its own validation logic and client software. While there are some common validation software being used, in the rare cases a blockchain development team decides to implement their custom validation logic, it is imperative to take blockchain reorgs into consideration.</p>
<p>Consider an example where a validation node always validates the oldest block. But because of reorgs, that block is often discarded and depending on the validation logic, the node may be slashed and lose funds.</p>
<p>Examples of this type of vulnerability seen in audits:</p>
<ul>
<li><p><code>01/09/2019</code><a target="_blank" href="https://solodit.xyz/issues/malicious-clients-can-use-forks-or-reorgs-to-convict-honest-nodes-wont-fix-consensys-slockit-incubed3-markdown"><strong>Malicious clients can use forks or reorgs to convict honest nodes</strong></a></p>
</li>
<li><p><code>01/09/2019</code><a target="_blank" href="https://solodit.xyz/issues/in3-server-should-enforce-safe-settings-for-minblockheight-wont-fix-consensys-slockit-incubed3-markdown"><strong>in3-server - should enforce safe settings for minBlockHeight</strong></a></p>
</li>
<li><p><code>12/09/2023</code><a target="_blank" href="https://solodit.xyz/issues/risk-of-double-spend-attacks-due-to-use-of-single-node-clique-consensus-without-finality-api-trailofbits-none-scroll-l2geth-pdf"><strong>Risk of double-spend attacks due to use of single-node Clique consensus without ﬁnality API</strong></a></p>
</li>
<li><p><code>19/12/2023</code><a target="_blank" href="https://solodit.xyz/issues/block-depth-used-does-not-offer-guarantees-against-reorgs-under-edge-cases-spearbit-none-redacted-dinero-infrastructure-pdf"><strong>Block depth used does not offer guarantees against reorgs under edge cases</strong></a></p>
</li>
</ul>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Blockchain reorganization is an event that has always existed and will probably exist for years to come. Reorgs impact specific application types and as such need to be taken into consideration otherwise severe financial loss may happen, as it has in the past.</p>
<p>As a manager, if the project your team is building is the type that can suffer when reorgs happen, share this link with your team and ask them to check. Resolving reorg issues should not have its own <a target="_blank" href="https://www.investopedia.com/terms/k/kpi.asp">KPI</a>, it is enough to include it in the (hopefully already existing) security related ones.</p>
<p>As an auditor you can either focus on the type of protocols that are susceptible to reorg issues or focus on the event itself. It is enough to ask the question:</p>
<blockquote>
<p>how would a block reorg affect this protocol?</p>
</blockquote>
<p>and to follow up from there to identify if such issues exist. The current article shows issues regarding specific products but a pattern can be deduced and applied to similar protocols.</p>
<hr />
<h1 id="heading-references">References</h1>
<ul>
<li><p><a target="_blank" href="https://dune.com/jacobdcastro/avg-block-times">Dune average block speed aggregator for popular blockchains</a></p>
</li>
<li><p><strong>Ethereum</strong></p>
<ul>
<li><p><a target="_blank" href="https://etherscan.io/blocks_forked">https://etherscan.io/blocks_forked</a></p>
</li>
<li><p><a target="_blank" href="https://etherscan.io/chart/blocktime">https://etherscan.io/chart/blocktime</a></p>
</li>
</ul>
</li>
<li><p><strong>Cronos</strong></p>
<ul>
<li><p>the only external source (without having a node) for block reorgs is <a target="_blank" href="https://cronos.org/explorer/reorgs">https://cronos.org/explorer/reorgs</a> which does not provide data in a user-friendly manner. The metrics in the article were extrapolated from monitoring the page sporadically during the day (I kid you not)</p>
</li>
<li><p><a target="_blank" href="https://cronoscan.com/chart/blocktime">https://cronoscan.com/chart/blocktime</a></p>
</li>
</ul>
</li>
<li><p><strong>Polygon PoS</strong></p>
<ul>
<li><p><a target="_blank" href="https://polygonscan.com/blocks_forked">https://polygonscan.com/blocks_forked</a></p>
</li>
<li><p><a target="_blank" href="https://polygonscan.com/chart/blocktime">https://polygonscan.com/chart/blocktime</a></p>
</li>
<li><p><a target="_blank" href="https://forum.polygon.technology/t/157-block-reorg-at-block-height-39599624/11388/2">https://forum.polygon.technology/t/157-block-reorg-at-block-height-39599624/11388/2</a></p>
</li>
</ul>
</li>
<li><p><strong>BNB Chain</strong></p>
<ul>
<li><a target="_blank" href="https://bscscan.com/blocks_forked">https://bscscan.com/blocks_forked</a></li>
</ul>
</li>
<li><p><strong>Avalanche C-Chain</strong></p>
<ul>
<li><p><a target="_blank" href="https://snowtrace.io/blocks">https://snowtrace.io/blocks</a></p>
</li>
<li><p><a target="_blank" href="https://pothu.medium.com/avalanche-consensus-explained-29b50d8a755c">https://pothu.medium.com/avalanche-consensus-explained-29b50d8a755c</a></p>
</li>
</ul>
</li>
<li><p><strong>Fantom</strong></p>
<ul>
<li><a target="_blank" href="https://fantom.foundation/intro-to-fantom/">https://fantom.foundation/intro-to-fantom/</a></li>
</ul>
</li>
<li><p><strong>Arbitrum One</strong></p>
<ul>
<li><p><a target="_blank" href="https://arbiscan.io/blocks">https://arbiscan.io/blocks</a></p>
</li>
<li><p><a target="_blank" href="https://arbiscan.io/chart/blocktime">https://arbiscan.io/chart/blocktime</a></p>
</li>
</ul>
</li>
<li><p><strong>Optimism</strong></p>
<ul>
<li><p><a target="_blank" href="https://chainstack.com/protocols/optimism/">https://chainstack.com/protocols/optimism/</a></p>
</li>
<li><p><a target="_blank" href="https://docs.optimism.io/chain/differences#eip-1559-parameters">https://docs.optimism.io/chain/differences#eip-1559-parameters</a></p>
</li>
</ul>
</li>
<li><p><strong>Base</strong></p>
<ul>
<li><a target="_blank" href="https://www.coinbase.com/cloud/discover/protocol-guides/guide-to-base">https://www.coinbase.com/cloud/discover/protocol-guides/guide-to-base</a></li>
</ul>
</li>
<li><p><strong>ZkSync Era</strong></p>
<ul>
<li><p><a target="_blank" href="https://docs.zksync.io/infra/component-breakdown.html#state-keeper-vm">reorg theoretically can happen</a></p>
</li>
<li><p><a target="_blank" href="https://docs.zksync.io/zk-stack/concepts/blocks.html#l2-blocks-aka-miniblocks">https://docs.zksync.io/zk-stack/concepts/blocks.html#l2-blocks-aka-miniblocks</a></p>
</li>
</ul>
</li>
</ul>
]]></content:encoded></item></channel></rss>