Order duration can be set to 0 by Malicious maker
A maker could create an order with a zero duration, causing it to expire immediately after a taker fills it. The taker would then be forced to withdraw at a loss due to fees on the strike price.
Originally disclosed on Code4rena
Submitted by codexploder, also found by ACai, cccz, Critical, horsefacts, ignacio, shenwilly, unforgiven, and xiaoming90
A malicious maker can set a minimum order duration as 0 which means order will instantly expire after filling. Taker will get only the withdraw option and that too with fees on strike price, thus forcing the taker to lose money in this meaningless transaction
Proof of Concept
- Maker creates an order with zero Order duration
- Taker fills this order but the order instantly expires since duration was 0
- Taker gets the only option to withdraw with fees on strike price
Recommended Mitigation Steps
Enforce at least x days of duration.
outdoteth (Putty Finance) confirmed and resolved:
PR with fix: https://github.com/outdoteth/putty-v2/pull/7.
hyh (warden) reviewed mitigation:
Fixed by requiring the minimal order duration of 15 minutes on filling.
Context
Putty is an options protocol. A maker writes an option order and a taker fills it. The order carries a duration, and a duration of zero means the order expires instantly after filling. The finding here concerns what happens when a maker is allowed to choose a duration of zero.
Setup
The report does not describe any accounts, tools, versions or environment. It is a code-level finding submitted to Code4rena against the Putty codebase, and it was also found independently by ACai, cccz, Critical, horsefacts, ignacio, shenwilly, unforgiven and xiaoming90. The only precondition is that a maker can create an order and a taker can fill it, which is the normal flow of the protocol.
Finding it
The researcher noticed that a maker can set the minimum order duration to 0. With a duration of 0, the order expires the instant it is filled. The taker has paid to fill an order that is already dead, and the only action left to them is to withdraw, and that withdrawal is charged fees on the strike price. The transaction is therefore meaningless for the taker and costs them money, while the maker controls the parameter that causes it.
Exploitation
Step 1: the maker creates an order with zero duration
The maker submits an order whose order duration is 0. The report gives no request, payload or code for this step; the point is simply that the value is accepted.
Step 2: the taker fills the order
The taker fills the order in the normal way. Because the duration was 0, the order expires immediately after filling rather than remaining live for any period.
Step 3: the taker can only withdraw, and pays fees
With the order expired, the taker is left with a single option: withdraw. That withdrawal carries fees on the strike price, so the taker ends up out of pocket on a transaction that gave them nothing.
Root cause
The order duration is a maker-controlled parameter and no lower bound was enforced on it. A duration of 0 is a valid input, and the expiry logic then treats the position as expired as soon as it is filled. No minimum duration was required.
Impact
A malicious maker can force a taker into a transaction that expires immediately, leaving the taker only the withdraw path and charging them fees on the strike price. The loss is the taker's money on a meaningless transaction. The report does not quantify the amount lost.
Fix
The reporter recommended enforcing at least x days of duration. The Putty team confirmed and resolved the issue, referencing a pull request with the fix, and the reviewing warden described the mitigation as requiring a minimal order duration of 15 minutes on filling.
Variants to test
- Set other numeric parameters to their boundary values (0, 1, maximum) at order creation and check whether the protocol accepts them and what the resulting state looks like after a fill. A positive result is a position that is immediately unusable or immediately chargeable to the counterparty.
- Check whether the minimum duration is enforced only at creation or also at fill time. If only one side checks it, try to reach the fill path with an order that bypasses the check. A positive result is a fill that succeeds with a duration below the intended minimum.
- Look for other maker-controlled fields that shift cost onto the taker, such as fee or strike parameters, and test whether they can be set to values that make the taker's only exit loss-making. A positive result is a taker whose only remaining action costs more than the position is worth.
Hunting notes
This kind of bug hides in the boundary values of user-supplied numeric parameters, especially durations, deadlines and expiry timestamps, where the code assumes a positive value but never enforces one. During review, look for parameters that are written by one party and consumed by another, and trace what happens at 0 and at the maximum. The report walked the sequence from order creation through fill to the taker's only remaining option. The team confirmed and resolved it, and the warden reviewed the mitigation as requiring a minimal order duration of 15 minutes on filling.
What happened, in plain words
Putty is a service for trading options. An option is a contract that gives someone the right to buy or sell something at an agreed price (the strike price) within a certain period. On Putty, one person, called the maker, writes an option order and sets its terms. Another person, called the taker, accepts that order by filling it. The order includes a duration, and a duration of zero means the order expires instantly after filling.
The problem is that the maker was allowed to set that duration to zero. A duration of zero means the position expires the very instant it is filled. The taker pays to fill an order that is already dead, and the only thing they can do afterwards is withdraw, and that withdrawal is charged fees on the strike price. So the taker loses money on a transaction that gave them nothing, while the maker controls the setting that causes it.
A malicious maker can force the taker to lose money on a meaningless transaction. The researcher who reported it is codexploder, and the same issue was found independently by ACai, cccz, Critical, horsefacts, ignacio, shenwilly, unforgiven and xiaoming90. It was submitted to Code4rena, a platform where people review code and report bugs for rewards, and the Putty team confirmed and resolved it.
Context
Putty is an options protocol. In everyday terms, think of a protocol as a set of rules written in code that several people can use without trusting each other, a bit like a vending machine: you put in your money, the machine follows its rules, and nobody needs a shop assistant in the middle. Here the machine handles option contracts.
Two roles matter:
- The maker writes an option order. They choose the terms, including the duration.
- The taker fills that order, paying to accept it.
The duration is the part that matters here. It decides how long the resulting position stays alive after the fill. If the duration is zero, the position is alive for no time at all: it expires the moment it is created.
Setup
The report does not describe any accounts, tools, versions or environment. It is a code-level finding: the researcher read the Putty code and reasoned about what happens when a maker chooses a duration of zero. No special software or access is needed to understand it.
The only precondition is the normal flow of the protocol: a maker can create an order and a taker can fill it. Nothing unusual has to be true for the bug to appear.
Finding it
The researcher noticed that a maker can set the minimum order duration to 0. In other words, the code accepts zero as a valid value.
With a duration of 0, the order expires the instant it is filled. The taker has paid to fill an order that is already dead. The only action left to them is to withdraw, and that withdrawal is charged fees on the strike price. The transaction is therefore meaningless for the taker and costs them money, while the maker controls the parameter that causes it.
Exploitation
The report lays the attack out as three steps. There is no request, payload or code for any of them; the point is the sequence of events and what each party is left with.
Step 1: the maker creates an order with zero duration
The maker submits an order whose order duration is 0. The report gives no request, payload or code for this step; the point is simply that the value is accepted. This step is taken because the maker wants to create a position that will not survive the fill, and the code lets them do it.
Step 2: the taker fills the order
The taker fills the order in the normal way. Because the duration was 0, the order expires immediately after filling rather than remaining live for any period. This step is taken because filling is what a taker normally does with an order they want; nothing in the order tells them the position will be dead on arrival.
Step 3: the taker can only withdraw, and pays fees
With the order expired, the taker is left with a single option: withdraw. That withdrawal carries fees on the strike price, so the taker ends up out of pocket on a transaction that gave them nothing. This step matters because it turns the bug into a concrete loss: the taker's only exit costs them money.
Root cause
The order duration is a maker-controlled parameter, and no lower bound was enforced on it. A duration of 0 is a valid input, and the expiry logic then treats the position as expired as soon as it is filled. No minimum duration was required.
A useful comparison is a shop that lets a customer set a "best before" date on a product they are selling. If the shop never checks that the date is in the future, a seller can put today's date, or a date in the past, and the buyer receives something that is already expired. The fix is the same in both cases: enforce a minimum.
Impact
A malicious maker can force a taker into a transaction that expires immediately, leaving the taker only the withdraw path and charging them fees on the strike price. The loss is the taker's money on a meaningless transaction. The report does not quantify the amount lost.
Fix
The reporter recommended enforcing at least x days of duration. The Putty team confirmed and resolved the issue, referencing a pull request with the fix, and the reviewing warden described the mitigation as requiring a minimal order duration of 15 minutes on filling.
Variants to test
These are ideas for finding similar bugs elsewhere. Each one is a variation on the same theme: a value chosen by one party that the other party has to live with.
- Set other numeric parameters to their boundary values (0, 1, maximum) at order creation and check whether the protocol accepts them and what the resulting state looks like after a fill. A positive result is a position that is immediately unusable or immediately chargeable to the counterparty. Boundary values are the edges of the allowed range, and code often forgets to handle them.
- Check whether the minimum duration is enforced only at creation or also at fill time. If only one side checks it, try to reach the fill path with an order that bypasses the check. A positive result is a fill that succeeds with a duration below the intended minimum. The lesson is that a check in one place does not protect a value that can arrive from another place.
- Look for other maker-controlled fields that shift cost onto the taker, such as fee or strike parameters, and test whether they can be set to values that make the taker's only exit loss-making. A positive result is a taker whose only remaining action costs more than the position is worth.
Hunting notes
This kind of bug hides in the boundary values of user-supplied numeric parameters, especially durations, deadlines and expiry timestamps, where the code assumes a positive value but never enforces one. During review, look for parameters that are written by one party and consumed by another, and trace what happens at 0 and at the maximum. The report walked the sequence from order creation through fill to the taker's only remaining option. The team confirmed and resolved it, and the warden reviewed the mitigation as requiring a minimal order duration of 15 minutes on filling.
Glossary
- Option: a contract giving one party the right to buy or sell an asset at an agreed price within a set period.
- Protocol: a set of rules written in code that multiple users can follow without trusting each other.
- Maker: the person who writes an option order and chooses its terms.
- Taker: the person who accepts and fills a maker's order.
- Order: a request to trade with specific terms, such as price and duration.
- Fill: the act of accepting an order and completing the trade.
- Duration: how long a position stays alive after the order is filled.
- Expiry: the moment a position stops being valid.
- Strike price: the agreed price at which an option can be exercised.
- Withdraw: the action of taking back funds or collateral from a position.
- Fees: a charge taken by the protocol on an action such as a withdrawal.
- Parameter: a value that a user or the code supplies to control how something behaves.
- Boundary value: the smallest, largest or otherwise extreme value a parameter can take, such as 0 or the maximum.
- Lower bound: the smallest value a parameter is allowed to have.
- Griefing: an attack where the goal is to cause loss or annoyance to another user rather than to profit directly.
- Root cause: the underlying reason a bug exists, as opposed to its visible symptoms.
- Mitigation: a change that removes or reduces the impact of a bug.
- Warden: a reviewer on Code4rena who checks reported findings and mitigations.
- Code4rena: a platform where researchers review code and submit bug findings for rewards.
- Pull request: a proposed change to a codebase that maintainers review before merging.