Skip to content
Business logic Audit finding Intermediate

Integration issue in ousgInstantManager with BUIDL if minUSTokens is set by blackrock

The BUIDL token contract can enforce a minimum balance that holders must keep after any transfer, but the ousgInstantManager contract does not account for this minimum when redeeming BUIDL. If BlackRock sets a non-zero minimum, redemptions that would leave the contract below that threshold would revert unexpectedly, breaking the instant redeem feature.

asui Follow

Originally disclosed on Code4rena

Submitted by asui

Integration issues with BUIDL, in the case blackrock decides to set a minimum amount of BUIDL tokens that should be held by its holders.

Proof of Concept

Blackrock implements a minUSTokens; variable where it sets a minimum amount to be held by the whitelisted addresses at all times. This check is done at every transfer. Currently, this is set to 0; but this could be set by blackrock at anytime.

    // get min us tokens
    function getMinUSTokens() public view override returns (uint256) {
        return minUSTokens;
    }

    // set min us tokens
    function setMinUSTokens(uint256 _value) public override onlyTransferAgentOrAbove {
        emit DSComplianceUIntRuleSet("minUSTokens", minUSTokens, _value);
        minUSTokens = _value;
    }

This is the code from the BUIDL token's contracts/compliance/ComplianceConfigurationService.Sol where the admin could set values for minUSTokens.

Also the line 238 in the contracts/compliance/Compliance/ServiceRegulated.sol is called when transferring token.

if (
                _args.fromInvestorBalance > _args.value &&
                _args.fromInvestorBalance - _args.value < IDSComplianceConfigurationService(_services[COMPLIANCE_CONFIGURATION_SERVICE]).getMinUSTokens()
            ) {
                return (51, AMOUNT_OF_TOKENS_UNDER_MIN);
            }

This essentially checks that the sender has at least the minimum amount of tokens after the transfer.

The problem is the ousgInstantManager doesn’t require that it always has this much amount of BUIDL. When redeeming, suppose it has 300k BUIDL and the minimum is say 10k BUIDL and an investor in Ondo wants to redeem 300k BUIDL tokens. It would still revert even though the contract has it, which could unexpectedly revert; violating one the main functionalities for Ondo (i.e. the instant redeem).

Code

Create a new test file and paste this code below:

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {Test, console} from "forge-std/Test.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IBUILDPause {
    function pause() external;
    function isPaused() external returns(bool);

}

interface IBUiLDRedeemer {
    function redeem(uint256 amount) external;
}
// 0x1e695A689CF29c8fE0AF6848A957e3f84B61Fe69
contract testBUILD is Test {
    // holders of BUILD tokens; just for test
    address holder1 = 0x72Be8C14B7564f7a61ba2f6B7E50D18DC1D4B63D;
    address holder2 = 0xEd71aa0dA4fdBA512FfA398fcFf9db8C49A5Cf72;
    address holder3 = 0xdc77C1D2A1dC61A31BE81e4840368DffEFAC3add;
    address holder4 = 0x1e695A689CF29c8fE0AF6848A957e3f84B61Fe69;
    address holder5 = 0xBc2cb4bF5510A1cc06863C96196a2361C8462525;
    address holder6 = 0xc02Ac677e58e40b66f100be3a721bA944807C2D7;
    address holder7 = 0x12c0de58D3b720024324d5B216DDFE8B29adB0b4;
    address holder8 = 0xb3c62fbe3E797502A978f418582ee92a5F327C23;
    address holder9 = 0x568430C66F9A256f609Ac07190d70c2c2573E065;

    // we get the owner form etherscan
    address ownerOfBUILD = 0xe01605f6b6dC593b7d2917F4a0940db2A625b09e;

    address build = 0x7712c34205737192402172409a8F7ccef8aA2AEc; // build token address
    IERC20 BUILD;

    uint256 MAINNET_FORK;

    function setUp() external {
        MAINNET_FORK = vm.createFork("https://eth-mainnet.g.alchemy.com/v2/IrK2bvsF-q028QswCasD1dQqxV8nqGMs");
        vm.selectFork(MAINNET_FORK);
        BUILD = IERC20(build);
    }

    function testBUILDHolderTransfer() public {
        address sender = holder1;
        address to = holder9;
        uint amountToSend = 90000000e6;

        uint totalBalance = BUILD.balanceOf(sender);

        vm.startPrank(sender); // random 5 million holder
        BUILD.transfer(to, amountToSend); // transfer 1 million to alice
        console.log(totalBalance);
        console.log(BUILD.balanceOf(sender));
        console.log(BUILD.balanceOf(to));
    }

    function testMinTokensUS() external { //0x1dc378568cefD4596C5F9f9A14256D8250b56369
        COMPLIANCE compliance = COMPLIANCE(0x1dc378568cefD4596C5F9f9A14256D8250b56369); // compliance configuration service
        console.log(compliance.getMinUSTokens());
        console.log(compliance.getUSLockPeriod());

        vm.startPrank(0xe01605f6b6dC593b7d2917F4a0940db2A625b09e); // owner address form etherscan
        compliance.setMinUSTokens(10000000e6);

        console.log(compliance.getMinUSTokens());
        vm.stopPrank();

        address sender = holder1;
        address to = holder9;
        uint amountToSend = 90000000e6;

        vm.startPrank(sender);
        BUILD.transfer(to, amountToSend);
        uint totalBalance = BUILD.balanceOf(sender);
        console.log(totalBalance);
        console.log(BUILD.balanceOf(sender));
        console.log(BUILD.balanceOf(to));

    }

Run forge test --mt testBUILDHolderTransfer which will pass but run forge test --mt testMinTokensUS -vvv, i.e. with the same amount after owner sets minUSTokens to 10 million, it will revert.

Note: 10 million is a very large amount and not realistic, it is just to show for the test because the holder 1 has more than 90 million BUIDL. I just set to 10 million to show it will revert. The real value set could be significantly lower than this.

Here in our example, when holder1 tries to transfer the code checks and notice that after transfer the holder will have less than the minimum, i.e. 10 million, so it reverts.

Tools Used

Foundry

Recommended Mitigation Steps

Import IDSComplianceConfigurationService or create an interface just for the getMinUSTokens() function and consider replacing the require statement in the _redeemBUIDL function with:

 function _redeemBUIDL(uint256 buidlAmountToRedeem) internal {
    require(
      buidl.balanceOf(address(this)) - IDSComplianceConfigurationService(0x1dc378568cefD4596C5F9f9A14256D8250b56369).getMinUSTokens >= minBUIDLRedeemAmount,
      "OUSGInstantManager::_redeemBUIDL: Insufficient BUIDL balance"
    );

The contract will never try to redeem more than its minimum allowed to hold and appropriately reverts with our error message: ”OUSGInstantManager::_redeemBUIDL: Insufficient BUIDL balance”

We get the address 0x1dc378568cefD4596C5F9f9A14256D8250b56369 of the complianceConfigurationService proxy by querying the BUIDL contract in etherscan using the function no.27 getDSService with 256 as the argument.

This minimum amount required may not be set currently but could be set by the admin in the future. So, implementing it now should be more compatible with BUIDL, even if in the future blackrock decides to set it.

Assessed type

Invalid Validation

cameronclifton (Ondo) acknowledged, but disagreed with severity and commented:

We will not mitigate this in the smart contract code. We plan to work with the BUIDL team to better understand the conditions in which minUSTokens will be set.

Note: For full discussion, see here.


The original report as published on Code4rena, by asui. 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 logic in ousgInstantManager does not reserve the BUIDL compliance minimum balance before transferring BUIDL out, so a transfer can push the contract below the minimum and be rejected by the token.

Impact

If BlackRock sets a non-zero minimum, instant redemptions of BUIDL through ousgInstantManager could revert, disrupting a core function; the text notes the minimum is currently zero and may never be set.

What the attacker needed

BUIDL admin sets a non-zero minimum; Contract holds BUIDL for redemptions

The fix

The redeem function should check that the contract's BUIDL balance minus the compliance minimum still covers the redemption amount, and revert with a clear error otherwise.

How it was found

  1. Fork mainnet and load the BUIDL token and its compliance configuration service.
  2. As the compliance owner, set the minimum BUIDL balance to a non-zero value.
  3. Have a BUIDL holder transfer an amount that would leave them below the minimum.
  4. Observe that the transfer reverts, showing the same check would block the Ondo contract's redemption.

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.

Some tokens have a rule that you must always keep a certain minimum amount in your wallet, checked on every transfer. If a contract that holds such tokens tries to send out so much that it drops below that minimum, the token refuses the transfer. Here the Ondo contract was not written to leave that minimum behind, so its redeem function could fail.

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 asui

View all

2 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.