Skip to content
Business logic Audit finding Intermediate

setPendingRedemptionBalance() may cause the user’s cash token to be lost

The setPendingRedemptionBalance function allows an admin to overwrite a user's pending redemption balance without checking the previous value. If a user increases their balance via requestRedemption before the admin's adjustment, the admin's call can overwrite the user's added amount, causing the user to lose cash tokens.

bin2chen Follow with chaduke

Originally disclosed on Code4rena

Submitted by bin2chen, also found by chaduke

setPendingRedemptionBalance() are not checking Old balances, resulting in the possibility of overwriting the new balance added by the user.

Proof of Concept

In setPendingRedemptionBalance(), MANAGER_ADMIN can adjust the amount of the cash token of user to be burned in some cases: addressToBurnAmt[user] Three main parameters are passed in.

    address user,
    uint256 epoch,
    uint256 balance

Before modification will check epoch can not be greater than the currentEpoch, is can modify the currentEpoch user balance.

This has a problem: The user is able to increase the addressToBurnAmt[user] of currentEpoch by requestRedemption() This leaves open the possibility that the user may have unknowingly executed requestRedemption() before settingPendingRedemptionBalance(), causing the increased balance to be overwritten

For example: currentEpoch = 1 Balance of alice: addressToBurnAmt[alice] = 50

  1. The administrator finds something wrong, there is 10 less, so he wants to increase it by 10, so he calls setPendingRedemptionBalance (balance=60)
  2. Alice does not know the above operation and wants to increase the redemption by 100, so it executes requestRedemption(100), which is executed earlier than setPendingRedemptionBalance() because the gas price is set higher
  3. The result is that the final balance of alice becomes only 60. change process: 50 => 150 => 60

The result is missing 100.

Suggest adding oldBalance, not equal will revert.

Recommended Mitigation Steps

Adding oldBalance, not equal will revert.

  function setPendingRedemptionBalance(
    address user,
    uint256 epoch,
+   uint256 oldBalance
    uint256 balance
  ) external updateEpoch onlyRole(MANAGER_ADMIN) {
    if (epoch > currentEpoch) {
      revert CannotServiceFutureEpoch();
    }
+   require(oldBalance == redemptionInfoPerEpoch[epoch].addressToBurnAmt[user],"bad old balance");

ali2251 (Ondo Finance) confirmed via duplicate issue #141


The original report as published on Code4rena, by bin2chen. 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 function setPendingRedemptionBalance lacks a check on the previous balance, allowing it to overwrite any concurrent user updates.

Impact

A user could lose the amount they added via requestRedemption if an admin's setPendingRedemptionBalance transaction overwrites it.

What the attacker needed

Admin calls setPendingRedemptionBalance; user calls requestRedemption before admin's tx

The fix

The function should be fixed by adding an oldBalance parameter and reverting if it does not match the current balance.

How it was found

  1. Admin calls setPendingRedemptionBalance with a new balance for a user.
  2. User calls requestRedemption to increase their balance before the admin's transaction is mined.
  3. Admin's transaction executes, overwriting the user's increased balance with the admin's value.

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 where an admin function can accidentally erase a user's recent deposit because it doesn't check the old balance. A user might add funds, but if an admin adjusts the balance afterwards, the user's addition is lost. The fix is to require the old balance to match before updating.

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