Skip to content
Business logic Audit finding Intermediate

Inadequate handling of BUIDL redemption limit in OUSG instant manager

The OUSG instant manager's redeem function checks the BUIDL balance against the full redemption amount, but if the manager holds enough combined BUIDL and USDC, a redemption that exceeds the BUIDL balance alone can still fail. An attacker could cause a legitimate user's redemption to revert by making a prior redemption that leaves the manager with insufficient BUIDL, even though the total value is sufficient.

Limbooo Follow with Bigsam

Originally disclosed on Code4rena

Submitted by Limbooo, also found by Bigsam

https://github.com/code-423n4/2024-03-ondo-finance/blob/78779c30bebfd46e6f416b03066c55d587e8b30b/contracts/ousg/ousgInstantManager.sol#L426-L429

https://github.com/code-423n4/2024-03-ondo-finance/blob/78779c30bebfd46e6f416b03066c55d587e8b30b/contracts/ousg/ousgInstantManager.sol#L460

Impact

The OUSG Instant Redemption Manager contract contains an oversight in its redeem function, specifically in the handling of BUIDL redemption limits. This oversight can potentially lead to failed redemption attempts when the redemption balance exceeds the BUIDL balance held by the manager contract while it has a right amount if its concatenated with USDC amount left by another redemption process. The impact of this issue is significant as it affects the usability of the redemption feature and can result in user frustration and loss of trust in the system.

Proof of Concept

The following POC demonstrates the issue. Use it as part of forge-tests/ousg/OUSGInstantManager/redeem.t.sol file.

Run using this command:

npm run test-forge -- --match-test test_POC_redeem_fail_when_alice_redeemtion_balance_is_over_manager_BUIDL_balance
  function test_POC_redeem_fail_when_alice_redeemtion_balance_is_over_manager_BUIDL_balance()
    public
    setupSecuritize(500_000e6, 500_000e6)
  {
    uint256 aliceOUSGRedeemAmount = 1667e18;
    uint256 aliceUSDCAmount = 250_100e6;

    uint256 bobOUSGRedeemAmount = 1666e18;
    uint256 bobUSDCAmount = 249_900e6;

    // Mint OUSG tokens for Alice and Bob
    vm.prank(address(ousgInstantManager));
    ousg.mint(alice, aliceOUSGRedeemAmount);

    vm.prank(address(ousgInstantManager));
    ousg.mint(bob, bobOUSGRedeemAmount);

    // Bob redeems OUSG tokens successfully
    vm.startPrank(bob);
    ousg.approve(address(ousgInstantManager), (bobOUSGRedeemAmount));
    ousgInstantManager.redeem(bobOUSGRedeemAmount);
    vm.stopPrank();

    // Alice attempts to redeem OUSG tokens, but the redemption fails due to insufficient BUIDL balance
    vm.startPrank(alice);
    ousg.approve(address(ousgInstantManager), (aliceOUSGRedeemAmount));
    vm.expectRevert('Not enough tokens');
    ousgInstantManager.redeem(aliceOUSGRedeemAmount);
    vm.stopPrank();

    assertEq(USDC.balanceOf(bob), bobUSDCAmount);

    assertEq(
      BUIDL.balanceOf(address(ousgInstantManager)) + USDC.balanceOf(address(ousgInstantManager)),
      aliceUSDCAmount
    );

    // However if Alice try to reddem an amount that will be in usdc amount <= minBUIDLRedeemAmount in ousgInstantManager it will success
    vm.startPrank(alice);
    ousgInstantManager.redeem(aliceOUSGRedeemAmount - 10e18);
    vm.stopPrank();

    // Tokens remaining in Alice's balance after successful redemption
    assertEq(ousg.balanceOf(alice), 10e18);

  }

Tools Used

Foundry

Recommended Mitigation Steps

To address this issue, the OUSG Instant Redemption Manager contract should implement a mechanism to ensure that redemption requests do not exceed the available BUIDL balance held by the manager contract. This can be achieved by incorporating proper checks and balances in the redemption process, such as verifying the BUIDL balance before processing redemption requests and adjusting the redemption amount accordingly. Additionally, consider an redeem implementation that concatenate the balance of remaining USDC amount with the BUIDL redeemed balance if the corresponding USDC amount or redeem amount of OUSG is more than minBUIDLRedeemAmount.

Assessed type

Error

cameronclifton (Ondo) confirmed and commented:

Due to changing requirements, the contract will now concatenate the USDC amount with BUIDL when performing redemptions. (This should mitigate this already known issue).

Note: For full discussion, see here.


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

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 redeem function checks the BUIDL balance against the full redemption amount without considering the USDC balance that could be combined to cover the redemption.

Impact

Legitimate users may be unable to redeem their OUSG tokens even when the contract holds sufficient total value, leading to failed transactions and loss of trust.

What the attacker needed

Manager holds BUIDL and USDC; user has OUSG to redeem

The fix

The contract should concatenate the USDC amount with BUIDL when performing redemptions, as the Ondo team confirmed they will do.

How it was found

  1. Mint OUSG tokens for Alice and Bob.
  2. Bob redeems his OUSG tokens successfully.
  3. Alice attempts to redeem her OUSG tokens, but the redemption fails due to insufficient BUIDL balance.
  4. Alice then redeems a slightly smaller amount that keeps the USDC portion within the minimum BUIDL redeem amount, and it succeeds.

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.

This is a smart contract bug in a system that lets people swap a token (OUSG) for another token (BUIDL) or for USDC. The contract checks if it has enough BUIDL to cover a redemption, but it forgets that it might also hold USDC from earlier redemptions. So a user can be blocked from redeeming even though the contract has enough total value, because the check only looks at BUIDL.

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 Limbooo

View all

12 more disclosed reports, best first.

More from Ondo Finance

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.