Options with a small strike price will round down to 0 and can prevent assets to be withdrawn
The fee calculation in PuttyV2 can round down to zero for small strike prices, causing a zero-value ERC-20 transfer that reverts for certain tokens. This prevents withdrawal of assets and the strike, locking them in the contract.
Originally disclosed on Code4rena
Submitted by berndartmueller, also found by auditor0517, hansfriese, IllIllI, Lambda, sashiketh, shenwilly, and TrungOre_
Impact
Certain ERC-20 tokens do not support zero-value token transfers and revert. Using such a token as a order.baseAsset for a rather small option strike and a low protocol fee rate can lead to rounding down to 0 and prevent asset withdrawals for those positions.
Proof of Concept
// send the fee to the admin/DAO if fee is greater than 0%
uint256 feeAmount = 0;
if (fee > 0) {
feeAmount = (order.strike * fee) / 1000;
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount); // @audit-info zero-value ERC20 token transfers can revert for certain tokens
}
Some ERC20 tokens revert for zero-value transfers (e.g. LEND). If used as a order.baseAsset and a small strike price, the fee token transfer will revert. Hence, assets and the strike can not be withdrawn and remain locked in the contract.
See Weird ERC20 Tokens - Revert on Zero Value Transfers
Example:
order.baseAssetis one of those weird ERC-20 tokensorder.strike = 999(depending on the token decimals, a very small option position)fee = 1(0.1%)
((999 * 1) / 1000 = 0.999) rounded down to 0 -> zero-value transfer reverting transaction
Recommended Mitigation Steps
Add a simple check for zero-value token transfers:
// send the fee to the admin/DAO if fee is greater than 0%
uint256 feeAmount = 0;
if (fee > 0) {
feeAmount = (order.strike * fee) / 1000;
if (feeAmount > 0) {
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount);
}
}
outdoteth (Putty Finance) confirmed and commented:
Report: withdraw() can be DOS’d for baseAsset ERC20s that prevent 0 transfers if the calculated feeAmount is 0 due to rounding.
outdoteth (Putty Finance) resolved:
PR with fix: https://github.com/outdoteth/putty-v2/pull/4.
hyh (warden) reviewed mitigation:
Context
Putty is an on-chain options protocol. The finding concerns PuttyV2.sol, specifically the fee handling inside the withdrawal path around lines 499 to 500. When a position is withdrawn, the contract calculates a protocol fee on the option strike and transfers that fee to the owner (the admin/DAO address).
The relevant code is:
// send the fee to the admin/DAO if fee is greater than 0%
uint256 feeAmount = 0;
if (fee > 0) {
feeAmount = (order.strike * fee) / 1000;
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount); // @audit-info zero-value ERC20 token transfers can revert for certain tokens
}
The fee is computed as (order.strike * fee) / 1000, an integer division. When the result is below 1, it rounds down to 0, and the contract still calls safeTransfer with a zero amount.
Setup
The report does not describe any accounts, tooling or deployed environment. The precondition is a position whose order.baseAsset is an ERC-20 token that reverts on zero-value transfers, combined with a small strike and a low protocol fee rate. The report cites LEND as an example of such a token and points to the "Weird ERC20 Tokens - Revert on Zero Value Transfers" list for background.
Finding it
The fee transfer runs whenever fee > 0. Because feeAmount is the result of integer division, it can be 0 while the transfer still executes. For tokens that do not support zero-value transfers and revert instead, that transfer aborts the whole withdrawal.
Exploitation
Step 1: Choose a base asset that reverts on zero-value transfers
Set order.baseAsset to one of the ERC-20 tokens that revert on a zero-value transfer, for example LEND.
Step 2: Use a small strike and a low fee so the fee rounds to zero
The report's example:
order.baseAssetis one of those weird ERC-20 tokensorder.strike = 999(depending on the token decimals, a very small option position)fee = 1(0.1%)
The calculation (999 * 1) / 1000 = 0.999 rounds down to 0, so the contract performs a zero-value transfer, which reverts the transaction.
Step 3: Observe the withdrawal failing
Because the fee transfer reverts, the withdrawal transaction as a whole reverts. The assets and the strike cannot be withdrawn and remain locked in the contract for that position.
Root cause
The fee is computed with integer division and the result is not checked before the transfer:
feeAmount = (order.strike * fee) / 1000;
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount);
When order.strike * fee is less than 1000, feeAmount is 0, yet safeTransfer is still called. For standard ERC-20 tokens a zero-value transfer is harmless, so nothing in the normal path surfaces the problem. For tokens that revert on zero-value transfers, the call fails and takes the entire withdrawal with it. The existing if (fee > 0) guard only checks the fee rate, not the computed amount, so it does not prevent the zero-value transfer.
Impact
For positions whose order.baseAsset is a token that reverts on zero-value transfers, and where the strike and fee rate are small enough that the fee rounds down to 0, the withdrawal reverts. The assets and the strike stay locked in the contract. The report frames this as affecting those positions specifically; positions in tokens that accept zero-value transfers are unaffected.
Fix
The recommended mitigation is to skip the transfer when the computed fee is zero:
// send the fee to the admin/DAO if fee is greater than 0%
uint256 feeAmount = 0;
if (fee > 0) {
feeAmount = (order.strike * fee) / 1000;
if (feeAmount > 0) {
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount);
}
}
Putty Finance confirmed the issue, describing it as withdraw() being open to denial of service for base asset ERC-20s that prevent zero transfers when the calculated feeAmount is 0 due to rounding. The team resolved it with a pull request (PR#4). A warden reviewing the mitigation noted that it was fixed together with H-01 in the same pull request.
Variants to test
- Other fee or amount calculations that can round to zero. Look for integer divisions feeding a token transfer, mint or burn. A positive result is a path where the computed amount is 0 but the external call still executes against a token that rejects zero values.
- Other weird ERC-20 behaviours in the same transfer path. The same unconditional call pattern can break on tokens with other non-standard behaviour. A positive result is a withdrawal or settlement that reverts only for a particular token.
- Guards that check the rate rather than the amount. Search for conditions like
if (fee > 0)that gate a transfer whose amount is derived separately. A positive result is a state where the guard passes but the amount is 0.
Hunting notes
This kind of bug hides in fee, royalty and settlement maths where an integer division result is passed straight into a token transfer. During review, the signal is a transfer call that is not preceded by a check on the computed amount, especially when the surrounding code only validates a rate or configuration value. The report made the impact concrete by naming the affected token class, giving a numeric example where the fee rounds to zero, and stating exactly what stays locked.
What happened, in plain words
Putty is a service that runs on a blockchain (a shared, public record of transactions that many computers keep in sync). It lets people create and trade options. An option is a contract that gives someone the right to buy or sell an asset at a fixed price, called the strike price, within a certain period. In Putty, the option and the money involved are held by a piece of software called a smart contract: a program that lives on the blockchain and runs automatically, with no human in the middle.
When a user closes a position and takes their assets back, the smart contract takes a small cut as a fee for the service and sends that fee to the service owner. The bug is in the part that calculates and sends that fee.
The calculation uses whole numbers only. If the fee works out to less than one whole unit of the token, the program rounds it down to zero. It then still tries to send a transfer of zero tokens to the owner. Most tokens accept a transfer of zero without complaint, but some tokens refuse it and cancel the whole transaction. When that happens, the user cannot withdraw anything: their assets and their strike stay stuck in the contract.
The researcher who found this is credited as berndartmueller, and the same issue was also found independently by auditor0517, hansfriese, IllIllI, Lambda, sashik*eth, shenwilly and TrungOre. The finding was rated medium severity.
Background you need first
A few ideas come up again and again below, so here they are from scratch.
- Blockchain and smart contract. Think of a blockchain as a public ledger that nobody can quietly edit. A smart contract is a small program stored on that ledger. Once deployed, it runs the same way for everyone, and its code is usually public.
- Token. A token is a digital asset managed by a smart contract. The most common standard for tokens on Ethereum-style blockchains is called ERC-20. The standard defines a fixed set of operations, including
transfer, which moves tokens from one address to another. - Address. An address is an account identifier on the blockchain, similar to a bank account number. It can belong to a person or to a contract.
order.baseAsset. In Putty, an order describes an option.order.baseAssetis the token that the option is written on, in other words the asset that changes hands.- Strike price. The fixed price at which the option can be exercised. In the code it appears as
order.strike. - Fee. The service's cut, expressed as a rate. In the code it appears as
fee, and the code divides by 1000, so afeeof 1 means 0.1%. - Integer division and rounding down. Computers that work with whole numbers cannot store 0.999. When you divide whole numbers, the fractional part is simply thrown away. So
999 / 1000gives0, not0.999. This is the heart of the bug. - Revert. When a smart contract hits a condition it cannot accept, it reverts: it cancels the transaction and undoes every change made during it, as if it never happened. A revert is the blockchain equivalent of a shop refusing a payment and handing everything back.
- Denial of service (DoS). A denial of service means making a feature unusable for legitimate users. Here it is not an attacker flooding the service; it is a normal withdrawal that can never succeed because of how the code is written.
Where the problem lives
The finding points at a specific place in the Putty source file PuttyV2.sol, around lines 499 to 500. That code runs during withdrawal: the moment a user closes a position and asks for their assets back. The contract works out the protocol fee on the strike, sends that fee to the owner address (the admin or DAO, a decentralised organisation that governs the service), and then returns the remaining assets to the user.
The relevant code is:
// send the fee to the admin/DAO if fee is greater than 0%
uint256 feeAmount = 0;
if (fee > 0) {
feeAmount = (order.strike * fee) / 1000;
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount); // @audit-info zero-value ERC20 token transfers can revert for certain tokens
}
Line by line, in plain words:
// send the fee to the admin/DAO if fee is greater than 0%is a comment explaining the intent: pay the fee only when a fee rate is set.uint256 feeAmount = 0;creates a whole-number variable calledfeeAmountand starts it at zero.uint256means an unsigned (non-negative) integer of 256 bits, the usual number type in this kind of code.if (fee > 0) {opens a block that only runs when the fee rate is above zero. If the service charges no fee at all, nothing inside runs.feeAmount = (order.strike * fee) / 1000;multiplies the strike by the fee rate and divides by 1000. Because this is whole-number division, any fraction is discarded.ERC20(order.baseAsset).safeTransfer(owner(), feeAmount);tells the base asset token to transferfeeAmounttokens to the owner address.safeTransferis a wrapper that also checks the transfer succeeded. The trailing comment is the researcher's note that a zero-value transfer can revert for certain tokens.- The closing
}ends the block.
The important detail is that the transfer on line 5 runs whenever fee > 0, regardless of what feeAmount turned out to be. Nothing checks whether the calculated amount is actually above zero.
Setting up the situation
The report does not describe any accounts, tools or deployed environment. What it does describe is the combination of conditions needed to hit the bug:
- A position whose
order.baseAssetis an ERC-20 token that reverts on zero-value transfers. - A small strike price.
- A low protocol fee rate.
The report names LEND as an example of a token that behaves this way, and points to a public list called "Weird ERC20 Tokens - Revert on Zero Value Transfers" for background. That list exists because the ERC-20 standard does not say what should happen on a zero-value transfer: most tokens treat it as a no-op, but some reject it outright.
Finding it
The fee transfer runs whenever fee > 0. Because feeAmount comes from whole-number division, it can be zero while the transfer still executes. For a token that rejects zero-value transfers, that single transfer aborts the entire withdrawal.
Exploitation, step by step
Step 1: Choose a base asset that reverts on zero-value transfers
Set order.baseAsset to one of the ERC-20 tokens that revert on a zero-value transfer, for example LEND. This is the ingredient that turns a harmless rounding quirk into a blocked withdrawal: with an ordinary token, sending zero would simply do nothing.
Step 2: Use a small strike and a low fee so the fee rounds to zero
The report's example:
order.baseAssetis one of those weird ERC-20 tokensorder.strike = 999(depending on the token decimals, a very small option position)fee = 1(0.1%)
The calculation (999 * 1) / 1000 = 0.999 rounds down to 0, so the contract performs a zero-value transfer, which reverts the transaction.
Walking through the arithmetic: 999 multiplied by 1 is 999. Dividing 999 by 1000 gives 0.999, but whole-number division keeps only the 0. The contract therefore calls safeTransfer asking to move 0 tokens. A token that refuses zero-value transfers rejects the call, and because a revert undoes everything in the transaction, the withdrawal as a whole is cancelled.
Step 3: Observe the withdrawal failing
Because the fee transfer reverts, the withdrawal transaction as a whole reverts. The assets and the strike cannot be withdrawn and remain locked in the contract for that position.
Root cause
The fee is computed with whole-number division and the result is not checked before the transfer:
feeAmount = (order.strike * fee) / 1000;
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount);
When order.strike * fee is less than 1000, feeAmount is 0, yet safeTransfer is still called. For standard ERC-20 tokens a zero-value transfer is harmless, so nothing in the normal path surfaces the problem. For tokens that revert on zero-value transfers, the call fails and takes the entire withdrawal with it. The existing if (fee > 0) guard only checks the fee rate, not the computed amount, so it does not prevent the zero-value transfer.
A useful comparison: a shop that says "we only charge a delivery fee if delivery is selected" but then still prints a delivery label for zero items. The condition checked (delivery selected) is not the condition that matters (is there anything to deliver).
Impact
For positions whose order.baseAsset is a token that reverts on zero-value transfers, and where the strike and fee rate are small enough that the fee rounds down to 0, the withdrawal reverts. The assets and the strike stay locked in the contract. The report frames this as affecting those positions specifically; positions in tokens that accept zero-value transfers are unaffected.
The fix
The recommended mitigation is to skip the transfer when the computed fee is zero:
// send the fee to the admin/DAO if fee is greater than 0%
uint256 feeAmount = 0;
if (fee > 0) {
feeAmount = (order.strike * fee) / 1000;
if (feeAmount > 0) {
ERC20(order.baseAsset).safeTransfer(owner(), feeAmount);
}
}
Line by line:
- The comment and the
feeAmountdeclaration are unchanged. - The outer
if (fee > 0)still checks that a fee rate is configured. - The fee is still calculated the same way, with the same rounding.
- The new inner
if (feeAmount > 0)checks the actual amount, not the rate. Only when the amount is at least one whole unit does the code proceed. - The transfer now sits inside that inner check, so a zero amount never reaches the token.
- The two closing braces close the inner and outer blocks.
The effect is that a fee which rounds to zero is simply not charged, and the withdrawal goes through.
Putty Finance confirmed the issue, describing it as withdraw() being open to denial of service for base asset ERC-20s that prevent zero transfers when the calculated feeAmount is 0 due to rounding. The team resolved it with a pull request (PR#4). A warden (a reviewer in the audit competition) reviewing the mitigation noted that it was fixed together with H-01 in the same pull request.
Variants to test
Three directions for looking for similar problems elsewhere:
- Other fee or amount calculations that can round to zero. Look for whole-number divisions feeding a token transfer, mint or burn. A positive result is a path where the computed amount is 0 but the external call still executes against a token that rejects zero values.
- Other weird ERC-20 behaviours in the same transfer path. The same unconditional call pattern can break on tokens with other non-standard behaviour. A positive result is a withdrawal or settlement that reverts only for a particular token.
- Guards that check the rate rather than the amount. Search for conditions like
if (fee > 0)that gate a transfer whose amount is derived separately. A positive result is a state where the guard passes but the amount is 0.
Hunting notes
This kind of bug hides in fee, royalty and settlement maths where a whole-number division result is passed straight into a token transfer. During review, the signal is a transfer call that is not preceded by a check on the computed amount, especially when the surrounding code only validates a rate or configuration value. The report made the impact concrete by naming the affected token class, giving a numeric example where the fee rounds to zero, and stating exactly what stays locked.
Glossary
- Address: an account identifier on a blockchain, like a bank account number; it can belong to a person or a contract.
- Blockchain: a public, tamper-resistant ledger of transactions kept in sync by many computers.
- DAO: decentralised autonomous organisation, a group that governs a service through on-chain rules rather than a single owner.
- Denial of service (DoS): making a feature unusable for legitimate users, here because a withdrawal can never succeed.
- ERC-20: the common standard that defines how tokens behave, including a
transferoperation. - Fee: the service's cut of a transaction, expressed as a rate; the code divides by 1000, so 1 means 0.1%.
- Integer division: division on whole numbers where the fractional part is discarded, so 999 / 1000 gives 0.
- Option: a contract giving the right to buy or sell an asset at a fixed price within a period.
order.baseAsset: the token an option is written on, the asset that changes hands.- Revert: cancelling a transaction and undoing all its changes when a condition cannot be met.
safeTransfer: a transfer helper that moves tokens and also checks the transfer succeeded.- Smart contract: a program stored on a blockchain that runs automatically and identically for everyone.
- Strike price: the fixed price at which an option can be exercised;
order.strikein the code. - Token: a digital asset managed by a smart contract.
uint256: an unsigned (non-negative) whole number of 256 bits, the usual number type in this code.- Warden: a reviewer participating in an audit competition who checks findings and mitigations.