Smart Contract Migration: Security Analysis and Recommendations from Ethereum to Arbitrum

Xueyan Tang, Lingzhi Shi, Alan Lai, Yuying Du, Jing Deng, Jialu Fu, Jiayi LiarXiv 2023 · DOI · arXiv

Introduction

As the blockchain ecosystem matures, Layer 2 (L2) scaling solutions have become essential for overcoming Ethereum's high gas fees and network congestion. However, a dangerous "copy-paste" fallacy has emerged among developers: the assumption that EVM-compatibility implies identical behavior across different environments. This paper, based on research by Xueyan Tang and Lingzhi Shi of Salus Security, explores the subtle security risks inherent in migrating smart contracts from Ethereum (L1) to Arbitrum (L2).

The Rise of Layer 2 Solutions

Arbitrum has emerged as a leader in the L2 space, offering significant scalability benefits. Its market dominance makes it a primary target for developers looking to migrate existing Ethereum dApps.

Figure 1: Market share of various Layer 2 solutions, highlighting Arbitrum One's leading position at 44.4%.

While the economic incentives are clear—with some protocols seeing up to a 99% reduction in transaction costs—the architectural differences between L1 and L2 introduce 36 distinct types of migration-related vulnerabilities.

Methodology

The study employed a mixed-method approach, combining academic literature review with deep-dive audits of 36 smart contract migration cases. These cases were sourced from prominent audit platforms like Code4rena, Cyfrin, and Halborn. The researchers also collaborated with Offchain Labs to validate technical findings regarding cross-chain messaging, block metadata, and sequencer behavior.

Key Technical Discrepancies

The research identifies four critical areas where Arbitrum's architecture deviates from Ethereum's standard behavior:

1. The Sequencer's Shadow

In Arbitrum, a sequencer is responsible for collecting and ordering transactions. If this sequencer goes offline, transactions are funneled into a "delayed inbox."

Figure 3: The mechanism of the Delayed Inbox and Sequencer, illustrating how transactions accumulate during downtime and execute upon restoration.

This delay can cause "asymmetric transaction conditions." For instance, a contract relying on real-time price oracles might execute based on stale data once the sequencer restores, creating arbitrage opportunities or liquidation risks that wouldn't exist on a continuously operating L1.

2. "Chunky" Time and Block Numbers

On Ethereum, block numbers increment predictably. On Arbitrum, the L1 block number (block.number) updates only about once per minute. Contracts using strict equality checks for block numbers may fail or behave unexpectedly because specific block numbers might never appear in the Arbitrum state.

3. The Address Alias Trap

To prevent contract impersonation during L1-to-L2 messaging, Arbitrum applies an "alias" to the sender's address. Migrated contracts that perform permission checks by comparing msg.sender to a hardcoded L1 address will fail, as the contract will see the aliased address instead.

4. Economic Barriers and DoS Attacks

Arbitrum is approximately 95.5% cheaper than Ethereum. While beneficial for users, this lower cost reduces the economic barrier for Denial of Service (DoS) attacks. Attackers can spam thousands of small transactions to congest a contract, a strategy that would be prohibitively expensive on the Ethereum mainnet.

Recommendations and Mitigation

To ensure a secure migration, the authors propose several key strategies:

  • Uptime Feeds: Implement Chainlink L2 Sequencer Uptime Feeds to verify sequencer health before executing sensitive logic.
  • Time Logic: Avoid strict equality checks on block numbers; use inequalities or time-based logic where possible.
  • Address Handling: Account for address aliasing in cross-chain messaging by using Arbitrum's built-in address transformation utilities.
  • Resource Management: Use mappings instead of unbounded arrays to prevent gas-limit DoS attacks, especially given the lower cost of transaction spam.

Conclusion

Migrating to Arbitrum offers undeniable advantages in cost and performance, but it is not a "plug-and-play" process. Developers must move beyond the assumption of perfect EVM-equivalence and account for the unique properties of L2 architecture. By adopting the recommended mitigation frameworks, the developer community can leverage the power of Layer 2 without compromising the security foundations established on Ethereum.

Summary updated

BibTeX
@misc{tang2023smart,
  author = {Xueyan Tang and Lingzhi Shi and Alan Lai and Yuying Du and Jing Deng and Jialu Fu and Jiayi Li},
  title = {{Smart Contract Migration: Security Analysis and Recommendations from Ethereum to Arbitrum}},
  year = {2023},
  eprint = {2307.14773},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2307.14773},
}
Figure