Redacted Cartel
A faulty implementation of the transferFrom function in the wxBTRFLY token allowed an attacker to reassign a user's allowance to themselves, enabling theft of that user's funds. The vulnerability put just under $6 million at risk.
medium.com
Published on medium.com
Bug Bounty
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Redacted Cartel's wxBTRFLY token is a wrapped version of xBTRFLY, built on Ethereum and intended to behave as a standard ERC-20. The ERC-20 standard is the most widely adopted token standard in the Ethereum ecosystem, and its approve(spender, amount) function lets any address spend tokens on behalf of the owner. If Alice approves Bob to spend 20 of her tokens, Bob's allowance is 20, and he moves those tokens with transferFrom(sender, recipient, amount).
OpenZeppelin publishes a framework of battle-tested implementations for standards such as ERC-20 and ERC-721, so developers do not need to re-implement the EIPs themselves. The bug described here came from a custom implementation of the standard ERC-20 functions in wxBTRFLY, specifically inside transferFrom, rather than from the OpenZeppelin code.

Setup
Whitehat Tommaso Pifferi submitted the vulnerability through Immunefi on 11 January. The report does not describe the researcher's tooling, accounts or environment beyond the contract under review. The relevant code is linked in the report at contracts/WXBTRFLY.sol in the REDACTED-Smart-Contracts repository; the fix section names the FrozenToken contract as the one containing the vulnerable transferFrom. The precondition for the attack is an ordinary ERC-20 pattern: a user holds wxBTRFLY and has granted an allowance to a contract.
Finding it
The issue lies in the highlighted section of the code.

The _approve function takes three arguments:
address owneraddress spenderuint256 amount
The function first sends the tokens from the sender's account to the recipient's account, on the first line of the code. Next, it decreases the allowance to account for the tokens that were just moved. That second step is where the problem sits.
Instead of reading and writing the allowance from the sender to the operator (msg.sender), the function reads the allowance from the sender to the recipient and writes the sender to the operator (msg.sender). The consequence is that a call to transferFrom ends up producing the recipient's approval minus the amount sent, rather than the sender's approval to the caller. That mismatch is what makes the allowance exploitable.
Exploitation
The attack lets a hacker take somebody else's allowance, assign it to themselves, and then use it to move the victim's funds to their own address. The report gives the following steps.
Step 1: the victim grants an allowance
Alice has 1000 wxBTRFLY and approves her contract to spend 1000 wxBTRFLY on her behalf. This is the normal ERC-20 approval flow, and it is the state the bug depends on.
Step 2: a zero-value transfer rewrites the allowance
Bob calls:
wxBTRFLY.transferFrom(Alice, aliceContract, 0)
No tokens move, because the amount is zero. But because of the allowance bug, Bob ends up with an allowance over Alice's money equal to 1000 wxBTRFLY. The call reads Alice's allowance to the recipient (aliceContract) and writes it against the operator, which is Bob.
Step 3: the funds are taken
Bob calls:
wxBTRFLY.transferFrom(Alice, bob, 1000)
and steals all of Alice's funds. The allowance Bob acquired in step 2 is what authorises this transfer.
Root cause
The mistake is in the custom transferFrom implementation in the FrozenToken contract. After moving tokens from sender to recipient, the code should read and write the allowance between the sender and the operator (msg.sender). Instead it reads the allowance between the sender and the recipient, and writes the result against the operator. The allowance bookkeeping therefore credits the wrong party: the caller gains an allowance equal to what the recipient was approved for, minus the amount transferred. A zero-amount transfer is enough to trigger the rewrite without moving any tokens.
Impact
A malicious attacker could assign a user's allowance to themselves and then steal that user's funds. Funds at risk were just under $6 million. The vulnerability was rated critical.
Fix
The new token version removed the FrozenToken contract, which contained the vulnerable transferFrom function. wxBTRFLY now relies on the ERC-20 implementation from OpenZeppelin. Redacted patched the bug and paid the whitehat $560,000 for the find.
Variants to test
- Custom
transferFromimplementations that adjust allowances after moving tokens. Compare the allowance read and written against the operator (msg.sender) with the one against the recipient; a positive result is an allowance that changes for the wrong address after a transfer. - Zero-amount
transferFromcalls. If a call with amount 0 changes any allowance, the bookkeeping is suspect; a positive result is a new or altered allowance for the caller without tokens moving. - Wrapped and derivative tokens that reimplement ERC-20 rather than inheriting OpenZeppelin. Check whether the allowance decrement uses the same pair of addresses as the transfer; a positive result is a mismatch between the spender checked and the spender debited.
- Contracts that inherit from a base token with a modified
transferFrom, such as theFrozenTokenpattern here. Confirm which implementation is actually deployed; a positive result is a live contract still exposing the custom function after a migration.
What happened, in plain words
Redacted Cartel runs a token on Ethereum, a public blockchain network. One of its tokens, wxBTRFLY, is a "wrapped" version of another token called xBTRFLY. Wrapping is a common pattern: you hand over one token and receive a receipt-like token that represents it, so it can be used in other places. The wxBTRFLY token was supposed to behave like a standard ERC-20 token, the most common kind of token on Ethereum.
A security researcher, Tommaso Pifferi, found a mistake in the code that handles one specific operation: letting someone else spend your tokens. Because of that mistake, an attacker could quietly take over another user's permission to spend tokens and then use it to move that user's tokens to themselves. The report says the funds at risk were just under $6 million. Redacted fixed the bug and paid the researcher $560,000.
This article walks through what the bug was, how the attack would have worked, and how it was fixed, in the same order as the technical write-up, but explained from scratch.

The image above is the header of the published review, titled "Redacted Cartel Custom Approval Logic Bugfix Review", credited to Immunefi and dated 28 March 2022.
Background concepts, from zero
Before the bug makes sense, a few ideas need to be clear.
Blockchain and Ethereum. A blockchain is a shared record book that many computers keep copies of. Ethereum is one such network. Programs called smart contracts live on it and run automatically. A token is a smart contract that keeps track of who owns how many units of something.
ERC-20. This is a written agreement (a "standard") about which functions a token contract must offer, so that wallets and other contracts know how to talk to it. Because everyone follows the same agreement, any wallet can display and move any ERC-20 token. Think of it like a standard plug shape: any device with that plug fits any socket.
approve(spender, amount). This function lets the owner of tokens give another address permission to spend a certain number of them. The permission is called an allowance. For example, Alice approves Bob to spend 20 of her tokens. Bob's allowance is now 20. This is useful because it lets a contract move your tokens for you, for example when you trade on a decentralised exchange, without you having to send them there first.
transferFrom(sender, recipient, amount). This is the function the approved party calls to actually move the tokens. It takes tokens from the sender and gives them to the recipient, and it is supposed to reduce the allowance by the amount moved, so the same permission cannot be used twice.
OpenZeppelin. A well-known project that publishes ready-made, widely reviewed code for standards like ERC-20 and ERC-721. Developers can reuse it instead of writing their own version of the standard, which reduces the chance of mistakes. The bug here was not in OpenZeppelin's code: it was in a custom implementation written for wxBTRFLY.
msg.sender. In a smart contract, this is the address of whoever triggered the current call. If Bob's wallet calls a function, then inside that function msg.sender is Bob's address. It is how the contract knows who is asking.
Critical severity. Bug bounty platforms rate findings by how much damage they could cause. Critical is the top level: it usually means direct loss of funds is possible.
The setup
The researcher submitted the vulnerability through Immunefi, a bug bounty platform for blockchain projects, on 11 January. The report does not describe his tools, accounts or working environment beyond the contract he reviewed.
The relevant code is linked in the report at contracts/WXBTRFLY.sol in the REDACTED-Smart-Contracts repository; the fix section names the FrozenToken contract as the one holding the vulnerable transferFrom.
The only precondition for the attack is an ordinary, everyday situation: a user holds wxBTRFLY and has granted an allowance to a contract. In other words, the victim has to have used the normal approval feature at least once. Nothing unusual is required of them.
Finding the bug
The issue lies in the highlighted section of the code.

The image shows the code excerpt with the faulty section highlighted, which is the part the analysis below refers to.
The _approve function takes three arguments:
address owneraddress spenderuint256 amount
In plain words: who owns the tokens, who is being allowed to spend them, and how many. address means a blockchain account identifier, and uint256 means a whole non-negative number.
The function first sends the tokens from the sender's account to the recipient's account, on the first line of the code. Next, it decreases the allowance to account for the tokens that were just moved. That second step is where the problem sits.
Instead of reading and writing the allowance from the sender to the operator (msg.sender), the function reads the allowance from the sender to the recipient and writes the sender to the operator (msg.sender).
That sentence is dense, so here it is slowly. Two different pairs of addresses are involved:
- The sender and the operator: the person whose tokens are being moved, and the person who triggered the call (
msg.sender). - The sender and the recipient: the person whose tokens are being moved, and the person receiving them.
The correct behaviour is to look up the allowance for pair 1 and reduce it, because the operator is the one spending. The buggy code instead looks up the allowance for pair 2 (the recipient's permission) and then writes the result against the operator. So the number that gets stored belongs to the wrong person.
The consequence is that a call to transferFrom ends up producing the recipient's approval minus the amount sent, rather than the sender's approval to the caller. That mismatch is what makes the allowance exploitable: the caller walks away with a permission that was never meant for them.
How the attack would work
The attack lets a hacker take somebody else's allowance, assign it to themselves, and then use it to move the victim's funds to their own address. The report gives three steps.
Step 1: the victim grants an allowance
Alice has 1000 wxBTRFLY and approves her contract to spend 1000 wxBTRFLY on her behalf. This is the normal ERC-20 approval flow, and it is the state the bug depends on. Alice is doing nothing wrong; she is using the token the way it is designed to be used.
Step 2: a zero-value transfer rewrites the allowance
Bob calls:
wxBTRFLY.transferFrom(Alice, aliceContract, 0)
Line by line:
wxBTRFLYis the token contract being called.transferFromis the function that moves tokens on someone's behalf.Aliceis the sender: the tokens would come from her account.aliceContractis the recipient: the address that would receive them. This is the same address Alice approved in step 1.0is the amount. Zero tokens are moved.
No tokens move, because the amount is zero. But because of the allowance bug, Bob ends up with an allowance over Alice's money equal to 1000 wxBTRFLY. The call reads Alice's allowance to the recipient (aliceContract) and writes it against the operator, which is Bob. In effect, Bob copies Alice's permission to aliceContract onto himself. The zero amount matters: it means the attacker pays nothing and moves nothing, yet still triggers the faulty bookkeeping.
Step 3: the funds are taken
Bob calls:
wxBTRFLY.transferFrom(Alice, bob, 1000)
Line by line:
Aliceis again the sender, so the tokens come from her balance.bobis the recipient, so the tokens go to the attacker.1000is the amount, which is everything Alice holds.
This steals all of Alice's funds. The allowance Bob acquired in step 2 is what authorises this transfer: as far as the contract is concerned, Bob is now an approved spender for 1000 of Alice's tokens.
Root cause
The mistake is in the custom transferFrom implementation in the FrozenToken contract. After moving tokens from sender to recipient, the code should read and write the allowance between the sender and the operator (msg.sender). Instead it reads the allowance between the sender and the recipient, and writes the result against the operator.
The allowance bookkeeping therefore credits the wrong party: the caller gains an allowance equal to what the recipient was approved for, minus the amount transferred. A zero-amount transfer is enough to trigger the rewrite without moving any tokens.
A useful comparison: imagine a cloakroom that hands out numbered tickets. You give your coat and get ticket 12. The attendant is supposed to cross off ticket 12 when someone collects the coat. Instead, the attendant looks at ticket 12 but crosses off the number of whoever is standing at the counter. The next person to walk in with that number can take a coat that is not theirs. The record was updated, but against the wrong person.
Impact
A malicious attacker could assign a user's allowance to themselves and then steal that user's funds. Funds at risk were just under $6 million. The vulnerability was rated critical. The exposure applies to users who have granted an allowance, since the attack works by taking over that existing approval.
The fix
The new token version removed the FrozenToken contract, which contained the vulnerable transferFrom function. wxBTRFLY now relies on the ERC-20 implementation from OpenZeppelin. In other words, instead of maintaining custom code for this operation, the project switched to the OpenZeppelin library version.
Redacted patched the bug and paid the whitehat $560,000 for the find.
What to look for elsewhere
These are the patterns worth checking in other projects, each with the sign that something is wrong.
- Custom
transferFromimplementations that adjust allowances after moving tokens. Compare the allowance read and written against the operator (msg.sender) with the one against the recipient; a positive result is an allowance that changes for the wrong address after a transfer. - Zero-amount
transferFromcalls. If a call with amount 0 changes any allowance, the bookkeeping is suspect; a positive result is a new or altered allowance for the caller without tokens moving. - Wrapped and derivative tokens that reimplement ERC-20 rather than inheriting OpenZeppelin. Check whether the allowance decrement uses the same pair of addresses as the transfer; a positive result is a mismatch between the spender checked and the spender debited.
- Contracts that inherit from a base token with a modified
transferFrom, such as theFrozenTokenpattern here. Confirm which implementation is actually deployed; a positive result is a live contract still exposing the custom function after a migration.
Glossary
- Allowance: a permission, stored by a token contract, that lets one address spend a set number of another address's tokens.
- Blockchain: a shared record book maintained by many computers, where entries are hard to change after the fact.
- Bug bounty: a programme that pays people for reporting security flaws responsibly instead of exploiting them.
- Critical: the highest severity rating, typically meaning direct loss of funds is possible.
- ERC-20: the common standard describing which functions an Ethereum token must offer.
- ERC-721: the equivalent standard for non-fungible tokens, where each token is unique.
- Ethereum: a public blockchain network that runs smart contracts.
FrozenToken: the contract in this project that contained the vulnerabletransferFromimplementation.- Immunefi: a bug bounty platform focused on blockchain projects.
msg.sender: inside a smart contract, the address of whoever triggered the current call.- OpenZeppelin: a project publishing ready-made, widely reviewed implementations of token standards.
- Operator: in this report, the address that triggered the call, that is,
msg.sender. - Recipient: the address receiving tokens in a transfer.
- Sender: the address whose tokens are being moved.
- Smart contract: a program stored on a blockchain that runs automatically when called.
- Spender: the address that has been granted an allowance to spend someone else's tokens.
transferFrom: the ERC-20 function that moves tokens from a sender to a recipient on the caller's behalf and reduces the allowance.uint256: a data type for whole, non-negative numbers, used for token amounts.- Whitehat: a security researcher who finds and reports vulnerabilities to help fix them.
- Wrapped token: a token that represents another token, so the underlying asset can be used in places that expect a standard format.
- wxBTRFLY / xBTRFLY: the project's tokens; wxBTRFLY is the wrapped version of xBTRFLY.