Characterizing Ethereum Upgradable Smart Contracts and Their Security Implications

Xiaofan Li, Jin Yang, Jiaqi Chen, Yuzhe Tang, Xing Gao

Abstract

Upgradeability in smart contracts presents a fundamental tension between the Ethereum "code is law" philosophy and the practical necessity for bug fixes and feature updates. While Upgradeable Smart Contracts (USCs) provide flexibility, improper implementation can introduce critical security vulnerabilities. This paper presents a large-scale measurement study of USCs on the Ethereum mainnet. We categorize five common USC patterns and introduce USCDetector, a tool designed to identify USCs and construct upgrade chains using only contract bytecode and transaction data. Evaluating USCDetector against a ground-truth dataset of verified contracts, we achieved 96.26% accuracy. Our analysis of over 60 million contracts identified 91,956 USCs and 10,218 upgrade chains, uncovering significant security risks, including contracts vulnerable to hijacking and permanent "bricking."

Introduction: The Immutability Paradox

The Ethereum ecosystem is built on the principle of immutability: once a smart contract is deployed, its code cannot be altered. This ensures trust and predictability for users. However, this rigidity poses a significant challenge when developers discover critical vulnerabilities or require functional upgrades. To resolve this "immutability paradox," the community developed architectural patterns that allow for logic updates while maintaining a persistent contract address and state.

Despite their utility, these Upgradeable Smart Contracts (USCs) introduce a new and complex attack surface. If the upgrade mechanism is poorly secured, an attacker can seize control of the contract, redirect funds, or render the contract unusable. While previous research has focused on verified contracts with available source code, a vast portion of the Ethereum ecosystem remains unverified. This study addresses this gap by analyzing the blockchain at scale using bytecode-level detection.

Taxonomy of Upgradeability

Through our analysis, we identified five primary patterns used to achieve upgradeability:

  1. Proxy Pattern: A proxy contract holds the state and delegates execution to a "logic" contract via DELEGATECALL. Upgrades occur by updating the logic contract's address in the proxy's storage.
  2. Data Separation: Logic and data are kept in separate contracts. Upgrades involve deploying a new logic contract and pointing it to the existing data contract.
  3. Strategy Pattern: The main contract delegates specific functional components (strategies) to external contracts, which can be swapped out.
  4. Migration Pattern: Data is manually or programmatically migrated from an old contract address to a new one.
  5. Metamorphic Pattern: Utilizing the CREATE2 opcode and SELFDESTRUCT, developers can redeploy different code to the same Ethereum address.

The USCDetector Framework

To analyze USCs without relying on source code, we developed USCDetector. The tool utilizes a multi-stage pipeline to identify and link USCs:

  • Bytecode Analysis: The tool pulls bytecode via RPC, disassembles it, and extracts function selectors by identifying "match and jump" patterns.
  • Keyword Filtering: We curated a list of 111 upgrade-related keywords (e.g., upgradeTo, setImplementation) and their corresponding 4-byte signatures to flag potential USCs.
  • Pattern Classification: Using rule-based detection, USCDetector classifies contracts into the five patterns based on the presence of specific opcodes (like DELEGATECALL) and the structure of the fallback function.
  • Upgrade Chain Construction: By analyzing transaction history, the tool links sequential versions of a contract, providing a longitudinal view of its evolution.

Large-Scale Measurement and Security Findings

We deployed USCDetector on the BigQuery Ethereum dataset, encompassing 60,251,064 smart contracts. The tool identified 91,956 USCs and successfully constructed 10,218 upgrade chains. Our analysis revealed several alarming security implications:

1. The Uninitialized Logic Vulnerability

In many Proxy implementations, developers initialize the proxy but neglect the logic contract itself. This allows an attacker to "claim" the logic contract. By calling SELFDESTRUCT on the logic contract, the attacker can "brick" the proxy permanently, as it now points to an empty address, freezing all associated assets.

2. Access Control Failures

We identified 27 USCs that lacked restrictive checks on their upgrade functions. In these cases, any user could potentially trigger an upgrade, allowing an attacker to replace the contract logic with a malicious version and hijack the entire system.

3. Zombie Contracts and Asset Danger

When contracts migrate to new addresses, the original "zombie" contracts often remain active. Our study found that users frequently continue to interact with these deprecated versions, which may contain known bugs or lack support, leading to significant "asset-in-danger" scenarios on Decentralized Exchanges (DEXs).

4. Complexity and the "Mix" Pattern

Modern DApps increasingly combine multiple patterns (e.g., a Strategy pattern calling a Proxy). This architectural complexity makes manual auditing nearly impossible and significantly increases the likelihood of logic errors that can be exploited.

Conclusion

Upgradeable Smart Contracts are a double-edged sword. While they provide a necessary path for evolution and security patching, they introduce structural risks that are often overlooked. USCDetector provides a scalable method for monitoring these risks in the wild, even for unverified contracts. Our findings suggest a dire need for better developer tooling and standardized security practices regarding initialization and access control in upgradeable architectures.

Summary updated

BibTeX
@inproceedings{li2024characterizing,
  author = {Xiaofan Li and Jin Yang and Jiaqi Chen and Yuzhe Tang and Xing Gao},
  title = {{Characterizing Ethereum Upgradable Smart Contracts and Their Security Implications}},
  booktitle = {WWW},
  year = {2024},
  url = {https://openreview.net/forum?id=rv1eAYaOx6},
}
Figure