Cointime

Download App
iOS & Android

Critical Infrastructure: Secure Engineering of Blockchain Bridges

Validated Project

Blockchain bridges enable users to transfer assets or data from one blockchain to another. Since most blockchains are developed in isolated environments and employ different rules and consensus mechanisms, they cannot communicate natively, and tokens cannot move freely between them. Bridges are designed to connect blockchains, facilitating the transfer of information and tokens between them.

What is a Cross-Chain Bridge?

The following is a simplified control flow of a bridge:

To initiate a transfer, the user must first deposit assets or data into the source chain contract, which will emit a deposit event. The backend server can range from a simple centralized server that monitors the emitted deposit event, verifies the transaction, and initializes the cross-chain transaction, to a more complex relayer chain. In the latter case, a series of relay nodes synchronize and monitor the transaction data of the blockchain, and the consensus nodes of the relay chain verify the validity of the cross-chain transactions and trigger the execution of the corresponding transactions. Once the target chain receives the signal to execute the transaction, the assets are sent to the user.

Trusted vs Trustless Bridges

Trusted bridges depend upon a central entity or system for their operations.They have trust assumptions with respect to the custody of funds and the security of the bridge. Users mostly rely on the bridge operator's reputation. Examples include Binance Bridge and Multichain.

Trustless bridges operate using smart contracts and algorithms. They are trustless, i.e., the security of the bridge “is the same” as that of the underlying blockchain. Examples include Connext Network and Hop Exchange.

What They Connect

  • L1 <> L1 Bridges: connect L1 blockchains with each other. For example, the Avalanche Bridge that connects Ethereum and Avalanche.
  • L1/L2 <> L2 Bridges: connect a certain baselayer with different L2 solutions and the L2s with each other. For example, Across is a bridge that connects Ethereum Mainnet to L2s like Arbitrum and Optimism. Hop Protocol connects different L2s with each other in addition to connecting the Ethereum Mainnet with them.

How They Move Assets

  • Lock & Mint: lock assets on the source chain and mint assets on the destination chain. Examples: Polygon’s PoS bridge, Avalanche Bridge, wrapped BTC, wMonero.
  • Liquidity Pools: Liquidity pools on each chain. Users receive their assets from the liquidity pool on the destination chain. Examples: Hop, Across.
  • Atomic Swaps: swap assets on the source chain for assets on the destination chain. Generally more trustless because they rely on smart contracts for swaps and remove the trusted third-party necessary in lock&mint or Liquidity Pools. Examples: cBridge, Connext.

How They Function

  • Chain-To-Chain Bridges: support the movement of assets between two blockchains. Generally, such bridges use the lock&mint mechanism. Examples: Native bridges such as Polygon’s PoS Bridge or Avalanche Bridge.
  • Multi-Chain Bridges: transfer assets across multiple blockchains. They are built such that they can be deployed to any L1 or L2 blockchain. Examples: Connext and cBridge.
  • Specialized Bridges: focused on specific ecosystems and designed to support the movement of assets. Due to specialization, they are generally faster and cheaper transactions.
  • Wrapped Asset Bridges: transfer of non-native assets to different blockchains. Creating wrapped assets on the destination representing the original asset on the source. Examples: wrapped BTC, wMonero.
  • Data Specific Bridges: interoperability protocols designed specifically for transferring arbitrary data across blockchains. Generally, these protocols become the base layer for dApps and make it possible for them to achieve cross-chain composability. Examples: Celer’s inter-chain Message Framework, IBC, Nomad.
  • dApp Specific Bridges: From a technical perspective, these are not bridges. By connecting to different blockchains, these dApps have built an ecosystem that allows value to be transferred across blockchains similar to bridges. Examples: Thorchain is a decentralized cross-chain AMM that offers cross-chain liquidity features that enable the exchange of assets across blockchains. Others: Anyswap, Wanchain, and Synapse.

Compared to other types of decentralized applications (dApps), blockchain bridges are more complex due to the greater number of components involved which result in a larger attack surface. Furthermore, the bridge contract often holds a substantial amount of assets as user deposits are stored within the contract. As a result, malicious actors are highly motivated to target cross-chain applications to steal large sums of funds. Bridge exploits can have significant implications for wrapped tokens as the loss of deposits may render the debt token worthless in extreme cases. In this article, we are examining several common vulnerabilities that have been exploited or that we have encountered during our audit.

Common Bridge Security Vulnerabilities

Insufficient Verification

The most crucial and must have process in a bridge system is validation. We can divide the validation into on-chain validation and off-chain validation.

On-Chain Validation

For simple bridges, especially those designed for specific dApps, on-chain validation is kept to a minimum. These bridges rely on the centralized backend to execute basic operations like minting, burning, or transferring tokens, while all verifications are performed off-chain. In contrast, other types of bridges use smart contracts to validate messages. In this scenario, when a user deposits funds on one chain, the smart contract generates a signed message and returns the signature in the transaction. This signature serves as proof of deposit and is used to verify the user's withdrawal request on the other chain. This process prevents various security attacks, including replay attacks and users forging deposit records. If there is a vulnerability during the validation process, the attacker can cause pretty serious damage. The BNB token hub hack occurred due to such a vulnerability. The attacker exploited a vulnerability in the precompiled contract for IAVL proof validation. The attacker generated forged proofs by adding leaves containing the attacker's payload hashes to the IAVL tree and inner nodes to finish the proof verification early. The attacker bypassed the IAVL proof validation and successfully minted two million BNB to their account.

Users are required to provide basic information about the cross-chain transfer they wish to make, such as the token they want to swap and the target chain. Without proper validation, unexpected operations may occur.

In January 2022, Multichain (previously known as Anyswap) was exploited due to validation bypass. Multichain is a cross-blockchain router protocol designed to enable users to swap and exchange digital tokens across chains while reducing fees and streamlining the overall process. The router wraps the actual token with its wrapped “anyToken '' to achieve this. For example, the DAI token is wrapped as anyDAI. Conversely, DAI is the underlying asset of anyDAI. The wrapped token is used for internal accounting, and when a user “transfers'' DAI from Ethereum to BSC, anyDAI is added to the Multichain anyDAI BSC contract and subtracted from anyDAI Ethereum contract.

The vulnerable function is anySwapOutUnderlyingWithPermit, which is used to swap an underlying token using the ERC20 permit function. The permit function enables users to supply a signed transaction approving a contract to spend their funds without actually sending it to the blockchain, thereby minimizing their gas cost. The signed transaction is expressed in (v, r, s) terms.

The attacker passed the following arguments to the function: 'from' represents the address of the victim, while 'token' and 'to' represent the attacker's deployed contract and the destination address, respectively. However, the attacker did not provide a valid signature for the 'v', 'r', and 's' parameters.

In the vulnerable function, the first line reads address _underlying = AnyswapV1ERC20(token).underlying();. The intention is to unwrap the underlying token, "DAI," from its AnyToken wrapping, "anyDAI." However, in this case, the token address is controlled by the attacker, and the contract returns WETH as its "underlying asset." WETH is not a wrapped token defined within the project.

The second line reads, IERC20(_underlying).permit(from, address(this), amount, deadline, v, r, s);. WETH contract does not implement the permit function. Instead, WETH has a fallback function called deposit, which does not perform any actions but allows the calling function to execute without failing.

The line TransferHelper.safeTransferFrom(_underlying, from, token, amount); would transfer tokens from the victim to the attacker-controlled contract. To execute this transfer, users must approve the router contract to spend an unlimited amount of their tokens. In this case, Multichain's dApp requested a practically infinite approval sum from all users, a common but insecure practice in dApps to save user expenses on gas.

By exploiting this excessive approval and a lack of input validation, the attacker was able to transfer the WETH amount from the victim's account to their controlled contract.

Off-Chain Validation

In a bridge system, the off-chain backend server typically assumes a centralized role in verifying the legitimacy of messages sent from the blockchain. This validation process typically focuses on verifying deposit transactions. The backend server must ensure that the deposit transaction it processes has actually occurred and has not been used for withdrawal on the target chain. As the backend server typically holds the privilege to determine whether a user can withdraw on the target chain, it is a high-value target for attackers. Two projects, QANX and Cennznet, have both been exploited due to attacks on their backend servers.

QANX serves as a bridge between the Ethereum (ETH) and Binance Smart Chain (BSC) networks, with the graph below illustrating the workflow of the bridge.

Source: QANplatform

At a high level, the bridge operates as follows:

  • Users interact with the user interface to make deposits into the smart contract on the source chain.
  • The user interface then sends the deposit transaction hash to the backend server via an API.
  • The transaction hash is subject to several validations on the server, and if it is deemed legitimate, signers will sign a message and send the signature back to the user interface via the API.
  • Upon receiving the signature, the user interface verifies it and permits the user to withdraw on the target chain.

The issue here is that when the backend server verifies the transaction, it only validates the structure of the emitted event of the transaction. It does not verify the contract address that emitted the event. Consequently, an attacker could deploy a malicious contract and create a transaction to forge a deposit event that has the same structure as a legitimate deposit event. The attacker could then send the transaction hash to the backend, bypassing verification and allowing them to withdraw from the target chain.

The hack on the Cennznet bridge is very similar to the QANX hack. In this case, the attacker deployed a contract to emit a deposit event, which the backend server picked up, allowing the attacker to drain funds from the bridge contract.

Validation is a critical aspect of the bridge system, and bypassing it can lead to significant financial losses, as illustrated above. Since each bridge has unique verification requirements, it is challenging to provide general guidance on ensuring the verification process is error-free. The most effective approach to preventing verification bypass is to test the bridge thoroughly against all possible attack vectors and ensure that the verification logic is sound.

Improper Handling of Native Tokens

Bridges take different approaches to managing the distinction between native tokens and utility tokens. For example, on the Ethereum network, the native token is ETH, and most utility tokens adhere to the ERC-20 standard. When a user intends to transfer their ETH to another chain, they must first deposit it into the bridge contract. To achieve this, the user simply attaches the ETH to the transaction, and the amount of ETH can be retrieved by reading the msg.value field of the contract.

Depositing ERC-20 tokens differs significantly from depositing ETH. To deposit an ERC-20 token, the user must first approve the bridge contract to spend their tokens. Then, when depositing the token to the bridge contract, the contract will either burn the user's token using the burnFrom function or transfer the user's token to the contract using the transferFrom function. Due to this distinction, the bridge contract must handle these two types of deposits separately. One approach is to use an if-else statement within the same function, while another method is to create two separate functions to handle each scenario. It is critical to consider what would happen if the user attempts to use the wrong function, such as attempting to deposit ETH using the ERC-20 deposit function, as seen in the Qubit hack.

The Qubit bridge functions to handle user deposits via two methods: deposit for ERC-20 token cross chain requests and depositETH for handling ETH transactions. In the attack on the bridge, the attacker exploited a vulnerability by calling the deposit function with specific parameters.

The crucial point to note is that the resourceID is set to "0x00000000000000000000002f422fe9ea622049d6f73f81a906b9b8cff03b7f01". The contract utilizes the resourceID to identify the type of token the user wishes to transfer cross-chain. The token address can be accessed via mapping resourceIDToTokenContractAddress. The resourceID used in the deposit function maps to the 0 address, which corresponds to ETH in the contract. Therefore, the attacker attempted to exploit the deposit function to handle ETH deposits, which was an unintended behavior. The verification process is carried out in the deposit function in the QBridgeHandler contract, as depicted below:

The deposit function in the Qubit bridge, which is designed to handle ERC-20 token cross chain requests, has two checks. Firstly, it requires the token address to be whitelisted (line 128). Secondly, it requires the user to transfer tokens to the contract (line 135). In the attack, the resourceID passed into the deposit function maps to the zero address, which represents ETH in the contract. There is no safeTransferFrom function implemented in the zero address. When the user tries to transfer tokens to the contract, the external call returns false, but the transaction can continue to execute. Unfortunately, even if line 135 returns false, the contract does not handle the case, allowing the transaction to be successfully executed.

Misconfiguration

In most blockchain bridges, there is a privileged role responsible for managing token and address whitelisting/blacklisting, assigning/changing signers, and other critical configurations. It is crucial to ensure that all configurations are accurate, as even seemingly trivial oversights can lead to significant hacks. In fact, some of the most significant hacks in recent years have resulted from such oversights.

For instance, in August 2022, the Nomad bridge was exploited, resulting in a loss of approximately $190M worth of assets. The bridge contract contains a process function that validates whether the transfer message is associated with a valid root. However, by default, the root for an unproven message would be 0x00.

A few days prior to the hack, a protocol upgrade took place where the trusted roots' value was initialized to 0x00. Although this is a common practice, in this particular case it also matches the value for an untrusted root. As a result, all messages are automatically considered proven, allowing anyone to submit an arbitrary message and pass the verification.

Building Better Bridges

Due to their high value, cross-chain bridges have long been the focus of attackers. We expect more attacks of this nature in the future. However, teams can strengthen their security measures by conducting thorough testing and engaging in third-party audits, reducing the risk of the devastating hacks that have plagued bridges over the last few years. Bridges are critical in a multi-chain world, but security must be a primary concern when designing and building effective Web3 infrastructure.

Read more: https://www.certik.com/resources/blog/2meXtRZZdL537Jaei9Jyt8-critical-infrastructure-secure-engineering-of-blockchain-bridges

Comments

All Comments

Recommended for you

  • Brookings Research: U.S. AI Infrastructure Investment Averages 3.63% of GDP, Three Times the Internet Boom

    On October 12, according to Wall Street Insights, Professor Stijn Van Nieuwerburgh of Columbia Business School pointed out in a recent paper from the Brookings Institution that the total investment in AI data center construction in the U.S. from 2025 to 2032 is expected to reach $10.3 trillion, averaging about 3.63% of GDP. This is 1.6 times the peak period of railroad construction from 1870 to 1890 and more than three times that of the internet and fiber optic boom. The construction cost for each 100-megawatt AI training facility is approximately $4.1 billion, with about two-thirds allocated for IT equipment. In terms of financing, Meta's Hyperion data center project, valued at around $30 billion, carries $27 billion in debt, resulting in a project-level debt-to-asset ratio of 90%. However, due to the debt being held within joint ventures and special purpose vehicles, it has not been included in Meta's balance sheet. Currently, approximately $1.4 trillion in debt is allocated for such structures, with about $700 billion to $800 billion held by banks. While he did not assert that AI has formed a bubble, he believes that off-balance-sheet financing makes it difficult for the market to see the complete economic responsibility.

  • Kremlin: Prepared to Suspend Strikes on Ukraine Election Day

    According to TASS, the Kremlin stated that it is prepared to suspend strike actions on Ukraine's election day.

  • Xinhua Media: Conducting Suspension Review

    On October 12, Xinhua Media announced that the company had reached the upper limit of its stock price for a total of 10 trading days from September 21, 2026, to October 12, 2026. The company will conduct a suspension review regarding stock trading fluctuations starting from October 13.

  • S&P 500 Futures Erase Early Gains

    On October 12, Dow Jones futures rose by 0.03%, S&P 500 futures increased by 0.01%, while Nasdaq 100 futures fell by 0.23%.

  • He Lifeng Meets Apple CEO Tim Cook

    On October 12, He Lifeng, a member of the Political Bureau of the Communist Party of China and Vice Premier of the State Council, met with Tim Cook, the Executive Chairman of Apple Inc., in the Great Hall of the People. He Lifeng stated that implementing the consensus reached by the leaders of the two countries and building a 'constructive and strategically stable relationship based on respect, fairness, and equality' is beneficial for the stability and development of both nations and the global economy, providing multinational companies with stable expectations and a favorable business environment. He welcomed technology companies from all countries, including Apple, to continue deepening mutually beneficial cooperation with China and to share in the opportunities of China's modernization. Cook expressed that Apple is confident in its long-term development in China and will serve as a communication bridge for the business community, contributing more to the stable and healthy development of Sino-U.S. economic and trade relations. (Xinhua News Agency)

  • U.S. Q3 Earnings Season Begins: Will Profit Growth Match Valuations?

    On October 12, the U.S. Q3 earnings season will kick off. Wall Street expects S&P 500 companies to report year-on-year profit growth of about 29%–31%, with approximately two-thirds of this growth coming from tech giants like Alphabet, Amazon, and Meta. The market's focus has shifted from 'whether profits will grow' to 'whether growth can match valuations.' Investors are paying attention to three key points: whether AI capital expenditures can be converted into revenue and profits, whether AI demand can spread to more industries, and whether companies are beginning to feel the impact of rising financing costs. Currently, the yield on 10-year U.S. Treasury bonds has risen above 5%, with high interest rates continuing to suppress valuations. Major banks will be the first to release earnings reports, providing signals on credit demand, credit quality, and interest rate trends. The biggest risk is that profit expectations are already fully priced in, and only significant positive surprises can drive valuation expansion; otherwise, high oil prices, high yields, and uncertainties in AI return cycles may lead to greater volatility. Earnings report schedule (Eastern Time): October 13 before the market opens: JPMorgan Chase, Goldman Sachs, Wells Fargo, Citigroup; October 14: Bank of America, Morgan Stanley, BlackRock, ASML; October 15: TSMC; late October: Tesla on October 21, Microsoft and Alphabet on October 27, Meta on October 28, Apple and Amazon on October 29 after market close, and Nvidia around November 17; cryptocurrency companies Coinbase and Strategy on October 29, and mining companies Marathon and Riot from late October to early November.

  • Hong Kong Stock Exchange Collaborates with S&P Dow Jones Indices to Launch Co-Branded Index

    The Hong Kong Stock Exchange has announced a collaboration with S&P Dow Jones Indices to develop and launch the S&P 500 Hong Kong Stock Exchange Technology 100 Index. This index aims to measure the performance of leading companies listed in the United States as well as the largest technology companies by market capitalization listed in Hong Kong. The index is approximately 60% allocated to the Hong Kong Stock Exchange Technology 100 Index and 40% to the S&P 500 Index, with weights adjusted quarterly.

  • LeCun et al. Propose H-JEPA Hierarchical World Model for End-to-End Learning in Visual Planning

    On October 12, according to an arXiv paper, researchers Wancong Zhang, Basile Terver, Michael Rabbat, Yann LeCun, and Randall Balestriero proposed H-JEPA, an end-to-end training scheme for a hierarchical action-conditioned JEPA world model, where each layer predicts further into the future within its learned latent space. Planning is conducted top-down: the top layer optimizes the goal, and each layer's predictions become sub-goals for the layer below. When factors in the data evolve at separate time scales, higher layers discard rapid, unpredictable details while retaining slower, task-relevant states. In four simulated navigation and manipulation environments, hierarchical planning outperformed flat JEPA; in the Visual AntMaze task, a three-layer structure increased the success rate from 18% to 73%, while requiring less computational power for planning. Ablation experiments indicate that the gains come from both temporal decomposition and high-level goal representation. Under inverse dynamics supervision, this method can be scaled to real robot videos in DROID.

  • Anthropic Bans 11.4 Million Accounts in Six Months, 42000 Appeals Overturned

    On October 12, Anthropic's transparency report updated on July 23 revealed that a total of 11.4 million accounts were banned in the first half of 2026. This is significantly higher than the 1.45 million accounts banned in the second half of 2025, marking an increase of approximately 7.9 times. The statistics cover all of Anthropic's products and services without distinguishing between Claude chat and developer products. During the same period, 398,000 appeals against account bans were received, of which 42,000 resulted in overturned decisions. Based on these figures, the number of overturned bans accounts for approximately 10.6% of the total appeals. Anthropic stated that accounts may be banned for violating usage policies, terms of service, or regional support policies.

  • 2026 Nobel Prize in Economic Sciences Announced

    On October 12, the Royal Swedish Academy of Sciences announced that Robert E. Hall and Michael Woodford have been awarded the Nobel Prize in Economic Sciences. They are recognized for developing new macroeconomic models that significantly enhance the ability to implement effective stabilization policies. Based on these models, timely fiscal and monetary policy measures can reduce the peaks and troughs of the economy. Robert E. Hall and Michael Woodford received this year's award for demonstrating how to reconstruct economic models to revitalize stabilization policies. Instead of building models based on statistical relationships among macroeconomic variables such as inflation, production, and consumption, they opted to establish a foundation based on microeconomic principles. This includes understanding how the overall behavior of households and businesses influences the economy. Robert E. Hall was born in 1943 in Palo Alto, California, and earned his Ph.D. from the Massachusetts Institute of Technology in 1967. He is a professor at Stanford University in California. Michael Woodford was born in 1955 in Chicopee, Massachusetts, and earned his Ph.D. from the Massachusetts Institute of Technology in 1983. He is a professor at Columbia University in New York.