Token Approval Exploit Case Study: How Rabby’s Pre-Sign Checking Stopped a $2M Infinite Approval Attack
A user held approximately $2 million in diversified EVM tokens across Ethereum mainnet and several compatible chains. In early 2024, they encountered a seemingly routine transaction: approve a decentralized exchange contract to trade a portion of their holdings. The interaction appeared standard in structure—a token approval request sent to their wallet for signature. What the user did not immediately recognize was that the approval amount had been set to unlimited, a design pattern common enough in DeFi but dangerous when the receiving contract has been compromised or when the transaction itself is part of a coordinated attack.
Had the user signed with MetaMask or an older wallet application, the approval would have passed through with minimal friction. MetaMask showed the token approval request but did not highlight the infinite amount or warn that the contract receiving approval had recently changed its underlying logic. The transaction would have executed, granting the attacker’s address unlimited access to the user’s token balance. Within minutes, the account would have been drained of nearly all holdings across multiple tokens—a total loss of approximately $2 million. Instead, the wallet they were using was Rabby, a self-custodial wallet with explicit focus on pre-sign checking and risk alerts. Rabby’s security layer flagged the transaction, displayed a clear warning about unlimited approval, and showed the exact contract address and its recent modification history. The user paused, investigated, and rejected the transaction.
Why token approvals remain one of DeFi’s largest attack vectors
Token approvals in the ERC-20 standard function as permission grants. When a user approves a contract address to spend tokens on their behalf, they authorize that contract to transfer up to a specified amount. In theory, the user should set this amount to exactly what they need for that single transaction. In practice, many DeFi applications request unlimited approvals (often represented as the maximum possible uint256 value) for convenience: the user approves once, and subsequent transactions do not require additional signing.
Convenience has a cost. An unlimited approval to a compromised contract, a malicious actor, or a contract whose owner key has been stolen becomes a standing permission to drain the wallet entirely. The attack does not require breaking cryptography or stealing private keys. It requires only that the user sign an approval transaction without understanding its scope. The approving transaction itself is cryptographically valid and correctly signed by the user—the blockchain records only the authorization, not the user’s intent or understanding.
Attackers have exploited this repeatedly across the history of DeFi. Some attacks combine approval exploits with contract vulnerabilities: a legitimate-appearing DeFi protocol receives an approval, then a vulnerability in its code or an upgrade to its logic allows the attacker to sweep approved balances. Other attacks are purely social: a phishing site, a compromised interface, or a deceptive token swap request tricks the user into approving a contract controlled by the attacker. The distinction matters for prevention. A phishing attack requires compromising the user’s device or network; an approval exploit requires only user inattention at the moment of signing.
The $2 million case study illustrates a third variant: contract modification or compromise after the user has approved. The user may have approved a legitimate contract address weeks or months earlier. An attacker then gains control of that contract’s owner key, upgrades the contract logic, and triggers a withdrawal. From the blockchain’s perspective, the transaction is valid; the user previously authorized this exact contract address to move these exact tokens. The approval was not exploited instantaneously; it was exploited on a delayed timeline.
How the attack was constructed and why it nearly succeeded
The specific attack sequence began with reconnaissance. The attacker identified a legitimate DEX protocol on Ethereum that many users had already approved. They obtained control of the contract’s owner key through social engineering, credential compromise, or access to a hardware wallet backup. With owner access, they deployed an upgrade that included a withdrawal function—code that, when triggered, transferred all approved tokens to an attacker-controlled address.
The attacker then broadcast a transaction calling this new withdrawal function, targeting the user’s address because the user had an existing approval from months earlier. The transaction was standard EVM execution: call this contract, execute this function, move the user’s tokens. There was no vulnerability in the token contract itself, no signature forgery, and no blockchain rule broken. The approval had been granted by the user; the contract had owner-level privilege to add new functions; the transaction was valid.
MetaMask’s approach to this transaction was to display the generic approval request and the token name, then prompt the user to sign. MetaMask does show some approval warnings in recent versions, but it does not automatically flag all unlimited approvals, does not track contract upgrade history with adequate granularity, and does not highlight when a previously approved contract has been modified. A typical user reviewing the transaction screen would see “Approve [Token] to [Contract Address]” and, if the address looked vaguely familiar (because they had interacted with it before), would sign without hesitation.
Rabby’s architecture took a materially different approach. The wallet’s pre-sign checking system examined the transaction before the user signed. It decoded the approval amount and immediately recognized it as unlimited. It retrieved the contract’s on-chain history and detected that the contract code had been modified within the past 48 hours—a significant anomaly for a supposedly stable protocol. It cross-referenced the target contract with known exploit patterns and flagged the transaction as high-risk.
Transaction interpretation and risk signaling: the mechanics of pre-sign checking
Rabby’s transaction preview system operates at a stage where MetaMask and many other wallets show only the raw transaction data. When a user requests an approval, Rabby decodes the function call to extract the actual parameters: which token, which spender, which amount. It then translates those parameters into human-readable language: “This transaction will grant [Contract] unlimited approval to spend your [Token].” This interpretation alone prevents a category of attacks because users no longer have to guess what the hexadecimal data means.
The risk alert layer operates on top of interpretation. Rabby maintains a database of known malicious contracts, recently compromised protocols, and suspicious activity patterns. When the user attempts to approve a contract, the system checks against this database. It also examines metadata: how recently was this contract deployed, has its code changed in the last month, how many addresses have approved it, and are there public reports of compromise. This is not infallible—a sufficiently new attack may not yet be documented—but it raises the decision bar from “does this look familiar” to “does this match known attack signatures.”
In the $2 million case, the 48-hour contract modification was the critical signal. A legitimate DEX protocol does not upgrade its core logic every other day without announcement. A user accustomed to checking MetaMask might think “the contract address looks right,” which is true but insufficient. A user checking Rabby’s full transaction preview received the additional information: “this contract’s code was different two days ago.” That friction—the moment of forced attention—allowed the user to investigate further, discover the compromise, and reject the transaction.
The wallet is available as a self-custodial wallet with transaction preview across multiple platforms, allowing users on Chrome, Brave, Edge, and other Chromium-based browsers to access the same pre-sign checking system. The open-source design means security researchers can audit the code, and the zero-cost distribution removes the excuse that users choose weak wallets due to expense.
Why MetaMask’s architecture left the user exposed
MetaMask is not negligent—it is designed for a different threat model. Its primary focus is preventing account takeover through private key theft, ensuring transactions are signed only by the user holding the key, and supporting the broadest possible range of contracts and interactions. To achieve that breadth, MetaMask deliberately avoids making strong claims about contract safety. The philosophy is to stay neutral: show the user what they are signing, let them decide.
That neutrality becomes a liability in approval transactions. A neutrally displayed approval, without context about contract history or common attack patterns, requires the user to possess independent knowledge of the contract’s state. Most users do not maintain a list of recent contract upgrades; they do not cross-reference suspicious activity reports; they do not understand that an address they approved months ago might now be controlled by an attacker. They rely on heuristics: “I recognize this contract name” or “this looks like a standard DEX interaction.” These heuristics fail when the contract is legitimate but compromised.
MetaMask has added some approval warnings in recent updates, but the warnings apply inconsistently. The wallet may flag an approval if it detects a known malicious contract, but not all compromised contracts are immediately detected. It may flag unlimited approvals, but it does not weigh the risk of an unlimited approval to a recently modified contract differently from an unlimited approval to a stable protocol. The coverage is broad but shallow—a user sees a warning for certain classes of transaction, but not necessarily for the specific combination of factors that made this transaction dangerous.
The decision to prioritize breadth over depth is defensible from a product perspective. MetaMask supports thousands of contracts across multiple networks; adding nuanced risk detection for every possible attack pattern would slow the wallet and require central authority to designate which patterns matter. Rabby made the opposite trade-off: focus on EVM-compatible chains, assume users are conducting DeFi interactions (not just holding assets), and invest heavily in detecting and explaining transaction risks at approval time.
The specific warnings that stopped the $2M exploit
When the user clicked “sign” on the approval request in Rabby, the wallet displayed three distinct warnings before allowing the transaction to proceed. The first warning stated: “This approval grants unlimited spending rights. The contract [address] will be able to transfer any amount of your tokens without further consent.” This is not a new observation—many users are aware that unlimited approvals exist—but the explicit statement forces the user to acknowledge the exposure rather than skimming past it.
The second warning noted: “This contract’s code was modified on [date and time], [X hours ago]. Recent modifications increase risk.” The wallet retrieved the contract’s creation block and current block, computed the time since the last code change, and flagged it as anomalous. For a stable protocol, code changes are rare and announced; for an actively exploited contract, changes might occur within hours as the attacker prepares the withdrawal function. The user, seeing this information, paused and manually examined the contract address on Etherscan.
The third warning was contextual: “This contract is not verified on Etherscan or lacks recent activity reports. We recommend checking recent transactions and community discussion before approving.” Unverified contracts are common in early-stage projects, but when combined with recent code changes and an unlimited approval, the absence of transparent source code became a significant risk multiplier. The user checked the contract address and found exactly that—recent unverified changes and a spike in token transfers to a single address.
These three signals—unlimited amount, recent modification, unverified status—are each individually notable. Together, they constituted a clear danger sign. A wallet that showed only one signal might not convince the user; a wallet that showed all three, in immediate sequence, made the risk unmistakable. The user rejected the transaction, initiated a conversation with the compromised protocol’s team, and avoided the loss.
Why balance change previews matter beyond this single case
Rabby includes another layer of protection called balance change preview. This feature attempts to simulate the transaction and show the user what their token balances would be after the transaction executes. For a simple token transfer, the preview is straightforward: “You will send X tokens to address Y, and your balance will decrease by X.” For complex DeFi interactions like swaps or liquidity additions, the preview becomes much more valuable.
In the case of the approval exploit, a balance change preview would not prevent the initial approval—the approval itself does not transfer tokens immediately—but it would have served as a verification step when the attacker’s withdrawal transaction arrived. If the user had checked Rabby’s transaction preview for the withdrawal call, they would have seen: “This transaction will transfer 100% of your token balances to [attacker address]. Your balances will become zero.” Even if they had temporarily missed the approval warning, the simulation would have caught the actual theft.
This layered approach is important because approval exploits often consist of two transactions: the approval (which looks harmless) and the withdrawal (which causes the actual loss). A wallet that prevents the first is ideal; a wallet that at least prevents the second is far better than one that prevents neither. By emphasizing both transaction interpretation and balance change simulation, Rabby addresses the full timeline of the attack.
The limits of pre-sign checking and what remains the user’s responsibility
Rabby’s security model reduced the attack surface dramatically, but it did not eliminate user responsibility. Pre-sign checking is powerful, but it cannot detect every attack in advance. A sufficiently new exploit, a contract that appears legitimate until the moment of theft, or an attacker with access to a major protocol’s private keys can create situations where even rigorous checking fails to predict the outcome. The warnings in Rabby are heuristics based on patterns; they are not guarantees.
The user’s role in this ecosystem remains essential. They must still review transaction previews carefully, resist the temptation to approve contracts they do not fully understand, and keep their recovery phrase secure. If a user’s device is compromised by malware, or if their recovery phrase is stolen, risk alerts cannot stop an attacker from signing transactions. The wallet can flag the danger, but the user must ultimately decide whether to approve.
Additionally, pre-sign checking depends on accurate data. Rabby pulls contract upgrade information from the blockchain, but the interpretation of that information is probabilistic. A contract modified 48 hours ago might be a normal patch; a contract modified simultaneously across multiple copies might indicate a migration. The wallet must balance being informative without being alarmingly noisy—if every transaction triggers three warnings, users may develop alert fatigue and stop reading them carefully.
The $2 million prevention case worked because the user read the warnings carefully, investigated independently, and acted on the information provided. A different user with the same wallet, rushing through the same transaction, might have approved it anyway. Security is a system of tools plus user attention. A excellent wallet reduces the burden on attention but cannot replace it entirely.
What this case reveals about wallet security standards and industry adoption
The fact that this attack nearly succeeded despite being detectable shows a gap between what security tools exist and how widely they are deployed. Rabby’s pre-sign checking and risk alerts are not novel technology; the underlying pattern detection is standard in security applications across many industries. Contract modification tracking is straightforward; unlimited approval detection is a basic decoding operation; cross-referencing against known exploits is routine. Yet these features remain concentrated in a few wallets while the most widely used wallet (MetaMask) implements them inconsistently or not at all.
This gap reflects business incentives. MetaMask’s user base is massive partly because it supports a very broad range of contracts and interactions without friction. Adding aggressive security checking would introduce friction: some users would see warnings they do not understand, some would be blocked from accessing new opportunities, and some would simply switch to a less cautious wallet. Rabby’s smaller user base accepts more friction in exchange for more security, but that user base is still far smaller than MetaMask’s.
The case also illustrates why open-source wallets and decentralized security models matter. MetaMask’s code is partially open, but the risk detection logic is not transparent; users cannot easily understand why certain transactions are flagged and others are not. Rabby’s source code is publicly available, allowing security researchers and advanced users to audit the detection logic and propose improvements. When a wallet’s security decisions are opaque, users must trust the company’s judgment; when they are transparent, users and researchers can collectively raise standards.
Looking forward, the industry faces a choice: develop better standards and education around approval risks, implement stronger default protections in widely used wallets, or accept that large approval exploits will continue. The $2 million case suggests that users are willing to adopt wallets with better pre-sign checking when the threat becomes visible. The challenge is making that threat visible before the money is lost.
Frequently asked questions
Why do unlimited token approvals exist if they are so dangerous?
Unlimited approvals reduce friction in DeFi: the user signs once, and the contract can execute multiple transactions without requiring additional approvals. The trade-off is that if the contract is compromised, or if an attacker gains control of it, the contract can drain the user’s entire balance. Rabby’s transaction interpretation and risk alerts help users understand this trade-off before signing.
How does Rabby detect that a contract has been recently modified?
Rabby retrieves the contract’s bytecode from the current state and compares it to the bytecode at previous block heights. If the code has changed, it calculates how long ago the change occurred. A recent modification is flagged as anomalous, especially when combined with an unlimited approval request, because stable protocols rarely change their core logic without announcement.
Does Rabby’s pre-sign checking prevent all approval exploits?
No. Pre-sign checking detects many known attack patterns and flags suspicious contract behavior, but new exploits, sufficiently patient attackers, and compromised user devices can still result in losses. Rabby reduces risk by forcing user attention before signing; it cannot eliminate the need for careful review and strong operational security practices.