Skip to content
Business logic Audit finding Intermediate

Auction.sol#settleAuction() Bonder may not be able to settle a bonded auction, leading to loss of funds

The settleAuction function checks that the new ratio is at least the minimum, but if the bonder bonded too late, this check always fails, leaving the bonder unable to settle and recover their bond. Another user can then burn the bond, causing the bonder to lose their funds.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

Auction.sol#L97-L102

    uint256 a = factory.auctionMultiplier() * basket.ibRatio();
    uint256 b = (bondBlock - auctionStart) * BASE / factory.auctionDecrement();
    uint256 newRatio = a - b;

    (address[] memory pendingTokens, uint256[] memory pendingWeights, uint256 minIbRatio) = basket.getPendingWeights();
    require(newRatio >= minIbRatio);

In the current implementation, newRatio is calculated and compared with minIbRatio in settleAuction().

However, if newRatio is less than minIbRatio, settleAuction() will always fail and there is no way for the bonder to cancel and get a refund.

Proof of Concept

Given:

  • bondPercentDiv = 400
  • basketToken.totalSupply = 40,000
  • factory.auctionMultiplier = 2
  • factory.auctionDecrement = 10,000
  • basket.ibRatio = 1e18
  • pendingWeights.minIbRatio = 1.9 * 1e18
  • Alice called bondForRebalance() 2,000 blocks after the auction started, paid 100 basketToken for the bond;
  • Alice tries to settleAuction(), it will always fail because newRatio < minIbRatio;
  • a = 2 * 1e18
  • b = 0.2 * 1e18
  • newRatio = 1.8 * 1e18;
  • Bob calls bondBurn() one day after, 100 basketToken from Alice will been burned.

Recommended Mitigation Steps

Move the minIbRatio check to bondForRebalance():

function bondForRebalance() public override {
    require(auctionOngoing);
    require(!hasBonded);

    bondTimestamp = block.timestamp;
    bondBlock = block.number;

    uint256 a = factory.auctionMultiplier() * basket.ibRatio();
    uint256 b = (bondBlock - auctionStart) * BASE / factory.auctionDecrement();
    uint256 newRatio = a - b;

    (address[] memory pendingTokens, uint256[] memory pendingWeights, uint256 minIbRatio) = basket.getPendingWeights();
    require(newRatio >= minIbRatio);

    IERC20 basketToken = IERC20(address(basket));
    bondAmount = basketToken.totalSupply() / factory.bondPercentDiv();
    basketToken.safeTransferFrom(msg.sender, address(this), bondAmount);
    hasBonded = true;
    auctionBonder = msg.sender;

    emit Bonded(msg.sender, bondAmount);
}

frank-beard (Kuiper) confirmed

0xleastwood (judge) decreased severity to Medium and commented:

While this issue is correct and I think this is a safer way to handle the require(newRatio >= minIbRatio) check, there are a few assumptions that are made. For example, it is assumed that the user bonds their tokens without checking minIbRatio and a publisher is able to maliciously update minIbRatio which must first go through timelock. Based on this, I’m more inclined to downgrade this to medium severity as I think this more accurately reflects the threat model.


The original report as published on Code4rena, by WatchPug. 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 minimum ratio check is performed only in settleAuction, not when the bond is created, so a bond can be placed that can never be settled.

Impact

The bonder may lose their bonded tokens because they cannot settle the auction and another user can burn the bond.

What the attacker needed

Auction is ongoing; bonder places bond after a certain block; another user calls bondBurn

How it was found

  1. Alice calls bondForRebalance() 2,000 blocks after the auction started, paying 100 basketToken as a bond.
  2. Alice tries to call settleAuction(), but it always fails because newRatio < minIbRatio.
  3. Bob calls bondBurn() one day later, and Alice's 100 basketToken bond is burned.

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.

In this auction system, a user (the bonder) puts up a deposit (bond) to help rebalance a basket of tokens. The code calculates a ratio based on when the bond was placed. If the bond is placed too late, the ratio falls below a required minimum, and the function that would return the bond always fails. As a result, the bonder cannot get their deposit back, and someone else can burn it.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Kuiper contest

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.