Many ERC-20 tokens deviate from the standard interface, and every such deviation creates its own risks. Sometimes this is simply a developer oversight, and sometimes it is a deliberate trap written with the express purpose of draining user funds. Non-standard tokens are so widespread that every new contract is worth checking before you do anything with it at all.
High-profile incidents make the seriousness of the problem clear. The Ronin Bridge hack in 2022 was primarily a bridge exploit, but it also involved custom token logic. The Multichain exploit in 2023 showed the same thing from a different angle: attackers targeted the complex, non-standard mechanisms of the bridge.
The attacker's reasoning is straightforward. Non-standard implementations are specifically targeted because they bypass the usual security checks that are designed for standard code. Everyone who interacts with decentralized applications (dApps, applications without a central operator) or simply holds tokens in a wallet is at risk. Understanding these risks is therefore important for everyone who participates in the DeFi ecosystem.
MECHANICS
A non-standard ERC-20 token may be missing required functions, or it may have them but with unexpected behavior. For example, the contract might lack a transfer function, or approve might be implemented in a way that allows double spending, where the same amount can be spent twice.
Attackers exploit these deviations in various ways. One common vector involves manipulating the transferFrom function, which is supposed to respect the granted allowance. If a token's transferFrom does not properly check or decrement the allowance, an attacker can transfer an amount exceeding the authorized limit.
The second mechanism involves a reentrancy vulnerability in custom token logic. If the contract calls external contracts before updating its own internal state, an attacker can trigger a recursive call and drain the contract's entire balance. This technique was behind many early DeFi exploits.
RED FLAGS
The primary signal is hidden in the source code. When reviewing a contract, look for deviations from the standard ERC-20 interface and verify that the required functions transfer, approve, and transferFrom are implemented the way you would expect. Beyond the code itself, there are smaller details that are easy to miss but also point to risk.
Here is what to check first:
- The
decimalsvalue: an unexpected number of decimal places may indicate manipulation or a bug that breaks price calculations. - Event logs: verify that the contract correctly emits the standard
TransferandApprovalevents; their absence or strange duplicates are a bad sign. - Upgradeability: assess whether the contract is upgradeable; proxy patterns (schemes that allow replacing the contract's logic) introduce new attack vectors if they are not managed securely.
- Creator and deployer addresses: examine their history for suspicious activity or connections to known malicious actors.
Keep block explorers and security analysis tools handy: they surface known vulnerabilities and red flags tied to a specific contract.
To make it clearer how a single deviation changes the picture, compare the behavior of a legitimate and a tampered transferFrom with a simple numerical example. Suppose you have granted a dApp an allowance of 100 tokens and your balance is 1,000.
transferFrom behavior |
What happens when tokens are transferred |
|---|---|
| Standard (legitimate) | At most 100 tokens are transferred; allowance is reduced to 0 |
| Tampered (malicious) | All 1,000 tokens are transferred; the 100-token limit is ignored |
The difference of one line of code translates into a difference of 900 tokens, which is exactly why verifying a function against the reference matters more than trusting the token's name.
PROTECTION
The baseline rule: always verify the contract against the ERC-20 standard using reputable audit tools. OpenZeppelin's ERC20 contract template, which the majority of reputable projects build on, provides a solid and secure foundation.
Prioritize tokens that have undergone a professional audit from a well-known firm. Do not stop at the fact of an audit: read the report to see what was found and whether it was fixed. When working with a dApp, separately confirm that the platform itself has strong security practices and that it vets the tokens it supports rather than accepting any contract indiscriminately.
Store significant amounts on hardware wallets. Before final confirmation, review the transaction details directly on the device screen, paying particular attention to what function is being called and with what parameters: this is where substitution most often hides.
AFTERMATH
The first and most urgent step is to contain the leak by revoking any token approvals granted to potentially compromised contracts or addresses. This can be done by calling approve(spender, 0) for the relevant token, or through a service that manages approvals and displays them as a list.
Next, report the incident. Notify the platform or exchange where the token was traded, and contact blockchain security firms such as Chainalysis or PeckShield. The more detailed the transaction data you provide, the better the chances that the investigation will move forward.
Recovering funds is a separate and difficult matter. Community-driven initiatives, legal action against the perpetrators if they can be identified, and law enforcement are all options. Direct recovery of money is rare, but even when it is not possible, your reports help track the attackers and prevent the next attack.