Skip to content
Business logic Audit finding Intermediate

A malicious attacker can create many orders that is not cancelable

The OracleLess contract allows any token address as tokenIn, so an attacker can create orders with a malicious token that reverts on transfer, making the order impossible to cancel. An attacker could create many such orders to grief the protocol and waste gas for other users.

covey0x07 Follow with vinica_boy

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-oku-judging/issues/331

Found by

covey0x07, vinica_boy

Summary

When a user creates an order in the OracleLess contract, he can add a malicous token contract that reverts when tokens are transferred from the OracleLess contract. This order can't be canceled by admin. A malicious attacker can create this kind of order as many as he can to grife the protocol.

Root Cause

At OracleLess.sol#L38, there is no restrictions for tokenIn. Any contract that implements IERC20 can be tokenIn.

Internal pre-conditions

N/A

External pre-conditions

N/A

Attack Path

  • Alice creates a malicous token contract that reverts if token is transferred from the OracleLess contract.
  • Alice creates orders by using this fake token contract.
  • This order can't be cancelable as it reverts at L160.
Solidity
    function _cancelOrder(Order memory order) internal returns (bool) { 
        //refund tokenIn amountIn to recipient
 @>     order.tokenIn.safeTransfer(order.recipient, order.amountIn);

Impact

  • A malicous attacker can grief the protocol by making a lot of uncancelable orders.
  • All users of the protocol wastes significant gas in whenever they fill or cancel orders.

Mitigation

It is recommended to add mechanism to whitelist tokens.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/gfx-labs/oku-custom-order-types/pull/1

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract does not restrict which tokens can be used as tokenIn, allowing malicious token contracts that revert on transfer.

Impact

A malicious attacker could grief the protocol by creating many uncancelable orders, causing all users to waste significant gas when filling or cancelling orders.

What the attacker needed

Attacker can create a malicious token contract; attacker can create orders

The fix

The protocol team fixed this issue by adding a mechanism to whitelist tokens.

How it was found

  1. Alice creates a malicious token contract that reverts if token is transferred from the OracleLess contract.
  2. Alice creates orders by using this fake token contract.
  3. This order can't be cancelable as it reverts at L160.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract lets users create orders using any token they specify. An attacker can use a fake token that always fails when the contract tries to send it back, so the order can never be cancelled. This lets the attacker clutter the system and make everyone else pay more in transaction fees.

What is Business logic?

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

More from Oku's New Order Types Contract Contest

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.