Skip to content
Business logic Audit finding Intermediate

when ReserveBase undercollateralized , Manager.orders will not be able to execute

The Manager contract assumes that redeeming reserve tokens always yields the same amount of USDC, but when the reserve is undercollateralised, redemption returns less. This causes order execution to fail with an insufficient balance error.

bin2chen Follow with panprog

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-perennial-v2-update-3-judging/issues/35

Found by

bin2chen, panprog

Summary

Manager.sol does not take into account that reserve.redeemPrice may be less than 1:1 The current code, reserve.redeem(amount) followed by a direct transfer of the same USDC, will fail because it results in an insufficient balance and the order will not be triggered successfully

Root Cause

in Manager.sol:219

If balance order.interfaceFee.unwrap=true, need to convert DSU to USDC Use reserve.redeem(amount); But this method, in the case of undercollateralized, is possible to convert less than amount, but the current code implementation logic directly uses amount.

Solidity
    /// @inheritdoc IReserve
    function redeemPrice() public view returns (UFixed18) {
        // if overcollateralized, cap at 1:1 redemption / if undercollateralized, redeem pro-rata
        return assets().unsafeDiv(dsu.totalSupply()).min(UFixed18Lib.ONE);
    }

    function _unwrapAndWithdaw(address receiver, UFixed18 amount) private {
        reserve.redeem(amount);
        USDC.push(receiver, UFixed6Lib.from(amount));
    }

Internal pre-conditions

No response

External pre-conditions

  1. XXXReserve.sol undercollateralized

Attack Path

  1. alice place TriggerOrder[1] = {price < 123 , interfaceFee.unwrap=true}
  2. XXXReserve.sol undercollateralized , redeemPrice < 1:1
  3. when price < 123 , Meet the order conditions
  4. keeper call executeOrder(TriggerOrder[1]) , but execute fail because revert Insufficient balance

Impact

No response

PoC

No response

Mitigation

Diff
    function _unwrapAndWithdaw(address receiver, UFixed18 amount) private {
-       reserve.redeem(amount);
-       USDC.push(receiver, UFixed6Lib.from(amount));
+       USDC.push(receiver, UFixed6Lib.from(reserve.redeem(amount)));
    }

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/equilibria-xyz/perennial-v2/pull/458

The original report as published on Sherlock, by bin2chen. 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

The code assumes a 1:1 redemption rate between reserve tokens and USDC, ignoring that the redeem price can be less than 1:1 when the reserve is undercollateralised.

Impact

Orders that require unwrapping the interface fee will fail to execute when the reserve is undercollateralised, potentially blocking order fulfilment.

What the attacker needed

Reserve is undercollateralised; order has interfaceFee.unwrap=true; order price condition is met

The fix

The fix was to use the actual amount returned by reserve.redeem when transferring USDC, rather than the requested amount.

How it was found

  1. Alice places a trigger order with interfaceFee.unwrap set to true.
  2. The reserve becomes undercollateralised, so the redeem price drops below 1:1.
  3. The price condition for the order is met.
  4. A keeper calls executeOrder, but the transaction reverts due to insufficient balance.

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 place orders that automatically trigger when a price condition is met. To pay a fee, it converts an internal token to USDC, assuming one token always equals one USDC. But if the reserve is undercollateralised, the conversion gives less USDC, so the transfer fails and the order cannot execute.

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 by bin2chen

View all

139 more disclosed reports, best first.

More from Perennial V2 Update #3

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.