Skip to content
Business logic Audit finding Intermediate

OUSGInstantManager will allow excessive OUSG token minting during USDC depeg event

The OUSGInstantManager contract mints OUSG tokens by treating USDC as if it were always worth exactly one US dollar, with no check on the actual USDC market price. During a USDC depeg, a user could hand over cheap USDC and receive OUSG worth more than what they paid, extracting value from the protocol.

Breeje Follow with Arz, HChang26 and 1 other

Originally disclosed on Code4rena

Submitted by Breeje, also found by Arz, HChang26, and immeas

Any user can use mint function in ousgInstantManager contract to mint OUSG tokens by providing USDC token. It calls internal function _mint where the main logic resides.

  function _mint(uint256 usdcAmountIn, address to) internal returns (uint256 ousgAmountOut) {

    // SNIP: Validation

    uint256 usdcfees = _getInstantMintFees(usdcAmountIn);
    uint256 usdcAmountAfterFee = usdcAmountIn - usdcfees;

    // Calculate the mint amount based on mint fees and usdc quantity
    uint256 ousgPrice = getOUSGPrice();
    ousgAmountOut = _getMintAmount(usdcAmountAfterFee, ousgPrice);

    require(ousgAmountOut > 0, "OUSGInstantManager::_mint: net mint amount can't be zero");

    // SNIP: Transfering USDC

    ousg.mint(to, ousgAmountOut);
  }

Two important points to understand

OUSG Price Stability:

The contract depends on the OUSG price obtained from an oracle, which is heavily constrained (as per Readme) to ensure stability.

OUSG Price - The OUSG price tracks an off chain portfolio of cash equivalents and treasury bills, price changes are heavily constrained in the OUSG Oracle, which uses the change in the price of SHV to set the allowable OUSG price in between updates. We are aware that the SHV price could differ from the OUSG portfolio, so any findings related to this price discrepancy is out of scope. Also, scenarios where the OUSG price increases by many orders of magnitudes are not realistic and consequently not considered valid.

As per RWAOracleRateCheck Oracle, constraints includes:

  1. OUSG price updates restricted to once every 23 hours.
  2. Price deviations limited to a maximum of 1%.
      function setPrice(int256 newPrice) external onlyRole(SETTER_ROLE) {
        if (newPrice <= 0) {
          revert InvalidPrice();
        }
 @->    if (block.timestamp - priceTimestamp < MIN_PRICE_UPDATE_WINDOW) {
          revert PriceUpdateWindowViolation();
        }
 @->    if (_getPriceChangeBps(rwaPrice, newPrice) > MAX_CHANGE_DIFF_BPS) {
          revert DeltaDifferenceConstraintViolation();
        }

        // Set new price
        int256 oldPrice = rwaPrice;
        rwaPrice = newPrice;
        priceTimestamp = block.timestamp;

        emit RWAPriceSet(oldPrice, newPrice, block.timestamp);
      }

These constraints ensure relative stability of the OUSG price.

Calculation Assumptions:

The calculation of the amount of OUSG tokens to mint assumes a fixed conversion rate of 1 USDC = 1 USD.

Key point: The _getMintAmount function calculates the OUSG amount based on the provided USDC amount and the OUSG price obtained from the oracle (by just upscaling and dividing).

  function _getMintAmount(
    uint256 usdcAmountIn,
    uint256 price
  ) internal view returns (uint256 ousgAmountOut) {
    uint256 amountE36 = _scaleUp(usdcAmountIn) * 1e18;
    ousgAmountOut = amountE36 / price;
  }

Here, there are no validation checks implemented regarding the current USDC price.

Scenario of the issue

Consider Alice’s attempt to mint OUSG tokens by providing 100,000 USDC, assuming no minting fees and OUSG price of 105e18 USD. The calculation yields: 100_000e36 / 105e18 which is approximately 95_000e18 or 95_000 OUSG tokens for the 100_000 USDC provided.

However, in the event of a USDC depeg, where USDC’s value deviates from 1 USD:

  • The contract’s calculation logic remains unchanged.
  • Despite the depeg, the OUSG price remains fairly constant (maximum 1% deviation allowed in 23 hours).

This scenario leads to Alice getting close to 95_000 OUSG tokens again for 100_000 USDC provided. But this time, 100_000 USDC can be worth as low as 87_000 USD if we take recent depeg event in March 2023, where USDC price went as low as 87 cents (reference).

This way, contract will allow users to mint excessive OUSG tokens during the depeg event.

Impact

Minting of excessive token in case of USDC depeg.

Tools Used

VS Code

Recommended Mitigation Steps

Ideally, there needs to be an additional Oracle to check current price of USDC and take its price into the consideration when calculation OUSG tokens to mint.

Assessed type

Context

3docSec (judge) increased severity to High and commented:

Upgraded as High because there is risk of value extraction from the protocol under conditions that can be monitored by an attacker.

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

After further review, we will be mitigating this by adding a Chainlink USDC/USD oracle to the OUSGInstantManager contract. If the price is lower than what we are comfortable with, all mints and redemptions will be blocked. While we think it is unlikely that we won’t be able to convert USDC->USD 1:1 in our backend systems, we decided to do this out of extreme caution.

Note: For full discussion, see here.


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

The mint calculation assumes a fixed 1 USDC = 1 USD rate and never consults a USDC price oracle.

Impact

During a USDC depeg an attacker could mint OUSG worth more than the USDC they supplied, extracting value from the protocol; the judge raised severity to High for this reason.

What the attacker needed

USDC trades below its $1 peg; attacker holds USDC to mint with

The fix

The team said it would add a Chainlink USDC/USD oracle and block mints and redemptions when the price falls below a comfortable threshold.

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.

OUSG is a token backed by cash-like assets, and the contract lets people swap USDC (a dollar-pegged stablecoin) for it. The code assumes one USDC is always worth one dollar, but stablecoins can lose their peg, as USDC did in March 2023 when it fell to about 87 cents. If that happens, someone could buy discounted USDC and swap it for full-value OUSG, leaving the protocol short.

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 Breeje

View all

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