Skip to content
Business logic Audit finding Intermediate

Zero strike call options will avoid paying system fee

The fee for options was calculated as a fraction of the strike price, so zero-strike calls incurred no fee and deep out-of-the-money calls incurred disproportionately high fees. An attacker could avoid paying system fees by using zero-strike call options.

hyh Follow

Originally disclosed on Code4rena

Submitted by hyh, also found by csanuragjain, minhquanym, and Treasure-Seeker

Zero and near zero strike calls are common derivative type. For such derivatives the system will not be receiving fees are the fee is now formulated as a fraction of order strike.

Also, it can be a problem for OTM call options, when the option itself is nearly worthless, while the fee will be substantial as strike will be big. Say 1k ETH BAYC call doesn’t have much value, but the associated fee will be 10x of usual fee, i.e. substantial, while there is nothing to justify that.

Marking this as medium severity as that’s a design specifics that can turn off or distort core system fee gathering.

Proof of Concept

Currently fee is linked to the order strike which makes it vary heavily for different types of orders, for example deep ITM and OTM calls:

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L494-L506

        // transfer strike to owner if put is expired or call is exercised
        if ((order.isCall && isExercised) || (!order.isCall && !isExercised)) {
            // 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);
            }

            ERC20(order.baseAsset).safeTransfer(msg.sender, order.strike - feeAmount);

            return;
        }

Recommended Mitigation Steps

Consider linking the fee to option premium as this is option value that cannot be easily manipulated and exactly corresponds to the trading volume of the system.

i.e. consider moving fee gathering to fillOrder:

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L322-L340

        // transfer premium to whoever is short from whomever is long
        if (order.isLong) {
            ERC20(order.baseAsset).safeTransferFrom(order.maker, msg.sender, order.premium);
        } else {
            // handle the case where the user uses native ETH instead of WETH to pay the premium
            if (weth == order.baseAsset && msg.value > 0) {
                // check enough ETH was sent to cover the premium
                require(msg.value == order.premium, "Incorrect ETH amount sent");

                // convert ETH to WETH and send premium to maker
                // converting to WETH instead of forwarding native ETH to the maker has two benefits;
                // 1) active market makers will mostly be using WETH not native ETH
                // 2) attack surface for re-entrancy is reduced
                IWETH(weth).deposit{value: msg.value}();
                IWETH(weth).transfer(order.maker, msg.value);
            } else {
                ERC20(order.baseAsset).safeTransferFrom(msg.sender, order.maker, order.premium);
            }
        }

Alex the Entreprenerd (warden) commented:

Zero strike will indeed have a fee of 0.

outdoteth (Putty Finance) confirmed and commented:

Report: Charging fees on the strike amount instead of the premium amount can lead to disproportionate fees.

outdoteth (Putty Finance) resolved:

PR with fix: https://github.com/outdoteth/putty-v2/pull/4.

hyh (warden) reviewed mitigation:

The same fix as in H-01.


The original report as published on Code4rena, by hyh. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

Putty is an on-chain options protocol. PuttyV2 is the contract that settles option orders: a maker writes an option, a taker fills it by paying a premium, and later the option is either exercised or expires. When the contract settles an order it also collects a protocol fee for the admin/DAO.

The report is about how that fee is calculated. In the version under review the fee is a fraction of the order strike, not of the premium. The author argues that this ties the protocol's revenue to a number that has no fixed relationship to the value actually traded, and that for some common option types the fee becomes zero or disproportionate.

Setup

The finding is a code review of the PuttyV2 contract, not a live exploitation against a deployed system. The relevant code is in contracts/src/PuttyV2.sol, in the settlement branch that runs when a put has expired or a call has been exercised (lines 494 to 506 of the reviewed commit).

No accounts, roles, tooling or versions beyond the contract source are described in the report. The issue arises when the protocol fee is configured above zero and the order is a zero or near-zero strike call, or an out-of-the-money call with a large strike.

Finding it

The researcher noticed that the fee is computed from order.strike. Two consequences follow directly from that formula:

  1. A call with a zero or near-zero strike produces a zero or near-zero fee, even though the order is a normal derivative that the system settles.
  2. A call that is far out of the money can have a large strike and therefore a large fee, even though the option itself is nearly worthless. The report's example is a 1k ETH BAYC call: the option does not have much value, but the associated fee will be 10x the usual fee, which is substantial with nothing to justify it.

The author classifies this as medium severity because it is a design specific that can turn off or distort core system fee gathering.

Exploitation

Step 1: Read the settlement fee calculation

The fee is taken in the branch that handles a put that has expired or a call that has been exercised:

Solidity
        // transfer strike to owner if put is expired or call is exercised
        if ((order.isCall && isExercised) || (!order.isCall && !isExercised)) {
            // 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);
            }

            ERC20(order.baseAsset).safeTransfer(msg.sender, order.strike - feeAmount);

            return;
        }

feeAmount is order.strike * fee / 1000. The fee is therefore a fixed fraction of the strike, independent of the premium the taker paid when the order was filled. With a strike of zero the product is zero, so the transfer to owner() is skipped and the whole strike (also zero) goes to msg.sender. With a large strike the fee scales up with it, whatever the option is worth.

Step 2: Compare with where the premium moves

The premium, which is the actual trading volume of the system, is transferred in fillOrder (lines 322 to 340 of the reviewed commit):

Solidity
        // transfer premium to whoever is short from whomever is long
        if (order.isLong) {
            ERC20(order.baseAsset).safeTransferFrom(order.maker, msg.sender, order.premium);
        } else {
            // handle the case where the user uses native ETH instead of WETH to pay the premium
            if (weth == order.baseAsset && msg.value > 0) {
                // check enough ETH was sent to cover the premium
                require(msg.value == order.premium, "Incorrect ETH amount sent");

                // convert ETH to WETH and send premium to maker
                // converting to WETH instead of forwarding native ETH to the maker has two benefits;
                // 1) active market makers will mostly be using WETH not native ETH
                // 2) attack surface for re-entrancy is reduced
                IWETH(weth).deposit{value: msg.value}();
                IWETH(weth).transfer(order.maker, msg.value);
            } else {
                ERC20(order.baseAsset).safeTransferFrom(msg.sender, order.maker, order.premium);
            }
        }

This is the flow the author points to as the correct basis for the fee: the premium is the option value that cannot be easily manipulated and exactly corresponds to the trading volume of the system. No fee is taken here in the reviewed code.

Step 3: Observe the two failure modes

No transaction trace is shown; the reasoning is arithmetic on the formula above. A zero strike call settles with feeAmount = 0, so the protocol collects nothing. A deep out-of-the-money call with a large strike settles with a fee proportional to that large strike, so the protocol collects a fee that is disproportionate to the option's value. The report notes that zero and near-zero strike calls are a common derivative type.

Root cause

The fee base is the wrong quantity. order.strike is a term of the option contract, not a measure of what was traded or what the option is worth, so a fraction of it does not track protocol usage. The existing check if (fee > 0) only guards against a zero fee rate; it does nothing when the strike itself is zero, because the multiplication still yields zero.

Impact

Under the conditions described, the protocol's fee gathering can be turned off (zero strike calls) or distorted (out-of-the-money calls with a large strike, where the fee is substantial relative to a nearly worthless option). The author frames this as a design issue affecting core system fee gathering and rates it medium.

Fix

The recommendation is to link the fee to the option premium rather than the strike, and to move fee gathering into fillOrder, where the premium is transferred. The project confirmed the report and resolved it with a pull request, summarising it as charging fees on the strike amount instead of the premium amount, which can lead to disproportionate fees. The author reviewed the mitigation and noted it is the same fix as in H-01 of the same audit.

Variants to test

  • Other fee formulas keyed to order terms. Look for fees computed from strike, notional, quantity or any maker-supplied field rather than from the amount actually transferred. A positive result is a settlement where the fee is zero for a non-zero-value trade, or a fee that scales with a field the maker controls independently of value.
  • Zero and near-zero values in arithmetic. Check every x * rate / denominator for inputs that can legitimately be zero, as strike can be for a call. A positive result is a fee branch that silently pays nothing while the trade still settles.
  • Fee taken at the wrong lifecycle step. Compare where value moves (fill, exercise, expiry) with where the fee is taken. A positive result is a fee base that is fixed at order creation and never reconciled with the premium actually paid.
  • Out-of-the-money extremes. Construct orders whose strike is far from the option's value and compare the fee with the premium. A positive result is a fee that is large relative to a nearly worthless option.

Hunting notes

This kind of bug hides in settlement and accounting code: the branch that distributes funds after exercise or expiry, and any place a fee, royalty or incentive is derived from a stored order field. During review, the signal is a fee expression whose base is not the transferred amount, especially one multiplied by a user-supplied parameter such as strike. The report showed impact by pairing the formula with two order shapes (zero strike calls and out-of-the-money calls with a large strike) and by pointing at the premium transfer as the value that the fee should track.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Putty is a piece of software that runs on a blockchain (a shared, public record of transactions that many computers keep in sync). It lets two people make a deal about an "option". An option is a contract that gives someone the right, but not the obligation, to buy or sell something at a fixed price later. That fixed price is called the strike.

Putty charges a small fee to the people who run the system (the admin, or a group called a DAO, a kind of organisation run by its members). The report is about how that fee is worked out. In the version being reviewed, the fee is a percentage of the strike, not of the money that actually changes hands when the deal is made. The money paid up front for an option is called the premium.

The researcher points out that this ties the system's income to a number that has no fixed relationship to what was really traded. For some common kinds of option the fee becomes zero, and for others it becomes far too large. The author rates this medium severity because it is a design choice that can switch off or distort the system's main way of collecting fees.

Setting the scene

This is a code review, not an attack on a live system. Nobody broke into anything. The researcher read the source code of a smart contract (a program that lives on the blockchain and runs automatically) called PuttyV2 and found a flaw in the arithmetic.

The relevant code is in the file contracts/src/PuttyV2.sol, in the part that runs when an option reaches its end: either a "put" has expired, or a "call" has been exercised. A put is an option to sell; a call is an option to buy. "Exercised" means the person holding the option chose to use their right.

The report does not describe any accounts, roles, tools or software versions beyond the contract source. The issue arises when the fee is set above zero and the order is a zero or near-zero strike call, or an out-of-the-money call with a large strike. Those shapes are calls with a zero or near-zero strike, and calls that are "out of the money" (explained below) with a large strike.

Finding it

The researcher noticed that the fee is calculated from order.strike. Two consequences follow straight from that formula:

  1. A call with a zero or near-zero strike produces a zero or near-zero fee, even though the order is a perfectly normal derivative that the system settles.
  2. A call that is far out of the money can have a large strike and therefore a large fee, even though the option itself is nearly worthless. The report's example is a 1k ETH BAYC call: the option does not have much value, but the associated fee will be 10x the usual fee, which is substantial with nothing to justify it.

"Out of the money" means the option's strike is on the wrong side of the current market price, so using the option right now would not be profitable. It is like holding a voucher to buy a loaf for £10 when shops sell it for £2: the voucher is nearly worthless, but the number printed on it is large.

The author calls this medium severity because it is a design specific that can turn off or distort core system fee gathering.

Exploitation

Step 1: Read the settlement fee calculation

The fee is taken in the branch that handles a put that has expired or a call that has been exercised:

Solidity
        // transfer strike to owner if put is expired or call is exercised
        if ((order.isCall && isExercised) || (!order.isCall && !isExercised)) {
            // 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);
            }

            ERC20(order.baseAsset).safeTransfer(msg.sender, order.strike - feeAmount);

            return;
        }

Line by line, in plain words:

  • The first comment says what this block does: it moves the strike amount to the owner when a put has expired or a call has been exercised.
  • The if line is the condition for entering this block. It is true when the order is a call and it was exercised, or when the order is not a call (a put) and it was not exercised (so it expired).
  • The next comment explains that the fee goes to the admin or DAO only if the fee rate is above zero percent.
  • uint256 feeAmount = 0; creates a variable to hold the fee, starting at zero. uint256 is a whole-number type in Solidity, the language smart contracts are written in.
  • if (fee > 0) { checks whether the fee rate is above zero.
  • feeAmount = (order.strike * fee) / 1000; is the heart of the issue. It multiplies the strike by the fee rate and divides by 1000. So the fee is a fixed fraction of the strike, with no reference to the premium the taker paid when the order was filled.
  • ERC20(order.baseAsset).safeTransfer(owner(), feeAmount); sends that fee amount to the owner (the admin or DAO). ERC20 is a standard for tokens on the blockchain, and safeTransfer is a transfer that checks it succeeded.
  • ERC20(order.baseAsset).safeTransfer(msg.sender, order.strike - feeAmount); sends the rest of the strike to whoever triggered this settlement (msg.sender is the person or program that called the function).
  • return; ends the function here, so nothing below runs.

With a strike of zero the multiplication gives zero, so the transfer to owner() is skipped and the whole strike (also zero) goes to msg.sender. With a large strike the fee scales up with it, whatever the option is worth.

Step 2: Compare with where the premium moves

The premium, which is the actual trading volume of the system, is transferred in a different function called fillOrder:

Solidity
        // transfer premium to whoever is short from whomever is long
        if (order.isLong) {
            ERC20(order.baseAsset).safeTransferFrom(order.maker, msg.sender, order.premium);
        } else {
            // handle the case where the user uses native ETH instead of WETH to pay the premium
            if (weth == order.baseAsset && msg.value > 0) {
                // check enough ETH was sent to cover the premium
                require(msg.value == order.premium, "Incorrect ETH amount sent");

                // convert ETH to WETH and send premium to maker
                // converting to WETH instead of forwarding native ETH to the maker has two benefits;
                // 1) active market makers will mostly be using WETH not native ETH
                // 2) attack surface for re-entrancy is reduced
                IWETH(weth).deposit{value: msg.value}();
                IWETH(weth).transfer(order.maker, msg.value);
            } else {
                ERC20(order.baseAsset).safeTransferFrom(msg.sender, order.maker, order.premium);
            }
        }

Line by line:

  • The first comment says the premium is moved from the person who is long (the buyer of the option) to whoever is short (the seller, who takes on the obligation).
  • if (order.isLong) { checks whether the order is a long one.
  • ERC20(order.baseAsset).safeTransferFrom(order.maker, msg.sender, order.premium); moves the premium from the maker (the person who created the order) to the caller. safeTransferFrom is a token transfer that also checks the sender has allowed it.
  • } else { handles the other case, where the caller is the long side and pays the premium.
  • The comment explains that this branch deals with someone paying the premium in native ETH (the blockchain's own currency) instead of WETH (a token version of ETH that behaves like any other token).
  • if (weth == order.baseAsset && msg.value > 0) { checks that the order's asset is WETH and that some ETH was actually sent with the call. msg.value is the amount of ETH attached to the transaction.
  • require(msg.value == order.premium, "Incorrect ETH amount sent"); stops the transaction unless the ETH sent exactly equals the premium. require is a check that cancels everything if it fails, and the text in quotes is the error message.
  • The next comment explains the conversion: ETH is turned into WETH and sent to the maker, and lists two benefits. First, active market makers will mostly be using WETH rather than native ETH. Second, the attack surface for re-entrancy is reduced. Re-entrancy is when a contract is called back into while it is still running, which can be abused if the code is not careful.
  • IWETH(weth).deposit{value: msg.value}(); converts the ETH into WETH.
  • IWETH(weth).transfer(order.maker, msg.value); sends the WETH to the maker.
  • } else { covers the ordinary case where the premium is paid in a normal token.
  • ERC20(order.baseAsset).safeTransferFrom(msg.sender, order.maker, order.premium); moves the premium from the caller to the maker.

This is the flow the author points to as the correct basis for the fee: the premium is the option value that cannot be easily manipulated and exactly corresponds to the trading volume of the system. In the reviewed code, no fee is taken here.

Step 3: Observe the two failure modes

No transaction trace is shown; the reasoning is arithmetic on the formula above. A zero strike call settles with feeAmount = 0, so the protocol collects nothing. A deep out-of-the-money call with a large strike settles with a fee proportional to that large strike, so the protocol collects a fee that is disproportionate to the option's value. The report notes that zero and near-zero strike calls are a common derivative type.

Root cause

The fee is calculated from the wrong quantity. order.strike is a term of the option contract, not a measure of what was traded or what the option is worth, so a fraction of it does not track how much the system is used. The existing check if (fee > 0) only guards against a zero fee rate; it does nothing when the strike itself is zero, because the multiplication still yields zero.

Impact

Under the conditions described, the protocol's fee gathering can be turned off (zero strike calls) or distorted (out-of-the-money calls with a large strike, where the fee is substantial relative to a nearly worthless option). The author frames this as a design issue affecting core system fee gathering and rates it medium.

Fix

The recommendation is to link the fee to the option premium rather than the strike, and to move fee gathering into fillOrder, where the premium is transferred. The project confirmed the report and resolved it with a pull request, summarising it as charging fees on the strike amount instead of the premium amount, which can lead to disproportionate fees. The author reviewed the mitigation and noted it is the same fix as in H-01 of the same audit.

Variants to test

  • Other fee formulas keyed to order terms. Look for fees computed from strike, notional, quantity or any maker-supplied field rather than from the amount actually transferred. A positive result is a settlement where the fee is zero for a non-zero-value trade, or a fee that scales with a field the maker controls independently of value.
  • Zero and near-zero values in arithmetic. Check every x * rate / denominator for inputs that can legitimately be zero, as strike can be for a call. A positive result is a fee branch that silently pays nothing while the trade still settles.
  • Fee taken at the wrong lifecycle step. Compare where value moves (fill, exercise, expiry) with where the fee is taken. A positive result is a fee base that is fixed at order creation and never reconciled with the premium actually paid.
  • Out-of-the-money extremes. Construct orders whose strike is far from the option's value and compare the fee with the premium. A positive result is a fee that is large relative to a nearly worthless option.

Hunting notes

This kind of bug hides in settlement and accounting code: the branch that distributes funds after exercise or expiry, and any place a fee, royalty or incentive is derived from a stored order field. During review, the signal is a fee expression whose base is not the transferred amount, especially one multiplied by a user-supplied parameter such as strike. The report showed impact by pairing the formula with two order shapes (zero strike calls and out-of-the-money calls with a large strike) and by pointing at the premium transfer as the value that the fee should track.

Glossary

  • Blockchain: a shared, public record of transactions kept in sync by many computers.
  • Smart contract: a program that lives on a blockchain and runs automatically when called.
  • Solidity: the programming language used to write smart contracts.
  • Putty: an on-chain options protocol; PuttyV2 is the contract that settles option orders.
  • Option: a contract giving the right, but not the obligation, to buy or sell something at a fixed price later.
  • Call: an option to buy.
  • Put: an option to sell.
  • Strike: the fixed price at which an option can be exercised.
  • Premium: the money paid up front for an option.
  • Maker: the person who creates an option order.
  • Taker: the person who fills an order by paying the premium.
  • Long: the side that buys the option.
  • Short: the side that sells the option and takes on the obligation.
  • Exercised: when the holder of an option chooses to use their right.
  • Expired: when an option reaches its end date without being exercised.
  • Out of the money: when exercising the option now would not be profitable.
  • Deep out of the money: far out of the money, so the option is nearly worthless.
  • In the money: when exercising the option now would be profitable.
  • Fee: the small amount the protocol collects for the admin or DAO.
  • DAO: a decentralised autonomous organisation, a kind of organisation run by its members.
  • ERC20: a standard for tokens on the blockchain.
  • ETH: the blockchain's own currency.
  • WETH: a token version of ETH that behaves like any other token.
  • msg.sender: the person or program that called the function.
  • msg.value: the amount of ETH attached to a transaction.
  • require: a check that cancels the whole transaction if it fails.
  • safeTransfer / safeTransferFrom: token transfers that check they succeeded.
  • uint256: a whole-number type in Solidity.
  • Re-entrancy: when a contract is called back into while it is still running, which can be abused if the code is not careful.
  • Severity: how serious a finding is judged to be.
  • Medium severity: a middle rating, here used because the issue can switch off or distort fee gathering.
  • Mitigation: a change that fixes or reduces a problem.
  • Pull request: a proposed change to code that can be reviewed and merged.

More by hyh

View all

137 more disclosed reports, best first.

More from Putty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.