The $3 million Swaprum rug pull on May 18, 2023 — executed through a malicious upgrade of a MasterChef staking contract on Arbitrum — has reignited urgent discussions about smart contract security verification. While Bitcoin holds at $26,832 and Ethereum trades at $1,802, the real story for DeFi developers and advanced users lies in understanding how upgradeable proxy patterns can be weaponized. This guide walks through the technical process of independently verifying smart contract integrity, with a focus on the proxy patterns that enabled the Swaprum exploit.
The Objective
This tutorial aims to equip advanced crypto users and developers with the technical skills needed to independently verify whether a deployed smart contract matches its audited source code, detect unauthorized contract upgrades, and assess the security implications of proxy patterns. By the end of this guide, you will be able to perform basic on-chain forensics on any upgradeable contract, identify red flags that indicate potential rug pull risk, and set up monitoring to detect malicious upgrades before they can affect your positions.
Prerequisites
To follow this guide effectively, you should have a working knowledge of Ethereum smart contracts, familiarity with block explorers like Etherscan and Arbiscan, and basic understanding of Solidity syntax. You will need access to a Web3-enabled browser or wallet, and optionally, a local development environment with Foundry or Hardhat installed for more advanced analysis. All techniques demonstrated here can be performed with free, publicly available tools.
Step-by-Step Walkthrough
Step 1: Identifying the proxy pattern. Navigate to the contract address on the relevant block explorer. For Arbitrum-based protocols, use Arbiscan. Look for indicators of a proxy pattern: the contract page will typically display a “Read as Proxy” or “Write as Proxy” tab alongside the standard Read/Write options. This indicates the contract delegates its logic to a separate implementation contract. Note both the proxy address and the implementation address — you will need both.
Step 2: Verifying the implementation contract. The proxy contract stores the user-facing address, but the actual code that executes lives in the implementation contract. Click through to the implementation address and check whether its source code is verified. If the implementation is unverified, you cannot confirm what code is actually executing — this is a major red flag. In Swaprum’s case, the malicious upgrade replaced the verified implementation with an unverified one, a change that would have been visible on-chain before funds were drained.
Step 3: Comparing audited vs. deployed code. Obtain the audited source code from the audit report. Most reputable auditors publish the commit hash or source code they reviewed. Use a diff tool to compare the audited version with the currently deployed implementation. Key differences to look for include new functions not present in the audit, modified access control logic, changes to fund transfer mechanisms, and alterations to admin or owner functions. In the Swaprum exploit, the malicious implementation introduced a new getToken function and modified the add function to drain liquidity — both changes that would have been immediately visible through code comparison.
Step 4: Analyzing the upgrade mechanism. Examine who has the authority to upgrade the proxy. Look for functions like upgradeTo, setImplementation, or similar proxy management functions. Check the access control on these functions — are they protected by a single externally owned account (EOA), a multi-signature wallet, or a governance contract? Single-key upgrade control is the highest risk configuration, as we saw with Swaprum. For maximum security, upgrade authority should be held by a timelocked governance contract with community participation.
Step 5: Setting up upgrade monitoring. Use blockchain monitoring tools to track changes to the implementation address. You can create a simple script using Etherscan’s API that periodically checks the proxy’s storage slot for the implementation address. The standard EIP-1967 implementation slot is 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc. A change to this value indicates a contract upgrade. For production monitoring, consider using Forta’s smart contract monitoring bots, which can alert you to proxy upgrades, ownership changes, and suspicious function calls in real-time.
Step 6: Evaluating the timelock. If the protocol uses a timelock for upgrades, examine the timelock contract’s parameters. What is the minimum delay between a proposed upgrade and its execution? Who can propose and execute upgrades? A 24-hour timelock gives the community time to react to malicious proposals, but only if someone is watching. Set up alerts on the timelock’s queue events so you are notified when an upgrade is scheduled.
Troubleshooting
Problem: The implementation contract source code is not verified on the block explorer. Solution: This is a critical warning sign. You can still examine the contract’s bytecode using tools like Dedaub’s Decomplier or Panoramix to get a rough understanding of the contract’s logic. However, unverified code should be treated with maximum suspicion, especially if the code was previously verified and then changed to unverified status.
Problem: The proxy uses a non-standard upgrade pattern that is difficult to analyze. Solution: Some protocols use custom proxy implementations rather than the standard OpenZeppelin patterns. In these cases, examine the proxy contract’s storage directly. The implementation address is typically stored in a specific storage slot. For EIP-1967 proxies, query slot 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc. For older proxy patterns like the ZeppelinOS proxy, check slot 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3.
Problem: You cannot determine who controls the upgrade mechanism. Solution: If the upgrade function’s access control is unclear or delegated to an unknown contract, trace the ownership chain. Use the block explorer to follow the owner or admin address through any intermediate contracts until you reach a terminal address. If this chain leads to a single EOA, the protocol has centralized upgrade control regardless of how complex the delegation chain appears.
Mastering the Skill
Smart contract security verification is an ongoing discipline, not a one-time task. To build lasting expertise, practice analyzing real protocols — start with well-known DeFi platforms like Uniswap or Aave and work your way down to newer, less-established projects. Join security-focused communities like the Smart Contract Security Forum or follow researchers who publish detailed exploit analyses. The Swaprum incident, where a CertiK-audited protocol with an “Out of Audit Scope” designation on its upgrade mechanism rug pulled for $3 million, demonstrates that even professional audits can leave dangerous blind spots. Your ability to independently verify contract integrity is the ultimate safeguard against these risks. Build a personal checklist, automate what you can, and never stop learning — the attack vectors evolve constantly, and your defenses must evolve with them.
Disclaimer: This article is for educational purposes only and does not constitute financial or investment advice. Technical analysis of smart contracts can help identify risks but cannot guarantee the safety of any protocol. Always conduct thorough research before committing funds to any DeFi platform.
the proxy admin slot check on etherscan is something every DeFi user should know how to do. takes 30 seconds and can save your entire stack
EIP-1967 implementation slot is 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc for anyone who wants to check directly
^ thanks for the actual slot hash, most guides just say check the proxy without explaining how
most audit reports dont even mention checking the proxy admin. its always contract is audited with zero mention that admin keys can rug
every audit i read says the contract is safe without mentioning that the admin can upgrade to a malicious implementation at any time. the fine print matters
bookmarked the slot. should be standard practice to check implementation slots before aping into any new defi protocol
saved that slot hash, thanks. bookmarked the etherscan method too. should be pinned on every DeFi discord
the Swaprum exploit was textbook. upgrade the implementation, drain the vault, done in one transaction. proxy patterns need better guardrails