Skip to content
Business logic Audit finding Intermediate

placeBid() Possible participation in auctions that have been modified

The placeBid function identifies an auction only by the comptroller address, so if the auction is restarted before a bid transaction is mined, the bid applies to the new auction instead of the one the user intended. This could cause the user to pay a large debt for little seized risk fund.

bin2chen Follow

Originally disclosed on Code4rena

Submitted by bin2chen

placeBid() lacks checking if auctions are restarted and participated in that are not expected by the user, which may result in the user losing funds.

Proof of Concept

When the user makes a bid, simply pass in comptroller and bidBps with the following code:

    function placeBid(address comptroller, uint256 bidBps) external nonReentrant {
        Auction storage auction = auctions[comptroller];

        require(_isStarted(auction), "no on-going auction");
        require(!_isStale(auction), "auction is stale, restart it");
        require(bidBps <= MAX_BPS, "basis points cannot be more than 10000");

Because comptroller corresponds to the Auction there are two cases that will generate new Auction (the new one and the old one may have completely different types and amounts):

  1. If the first auction takes too long and no one bids, _isStale() can restart the auction.
  2. If the auction ends and the last bid time >nextBidderBlockLimit, then you can restart the auction after it ends.

Since bidding can be restarted, placeBid() is only based on comptroller, and it may be possible to participate in the old Auction, but end up participating in the new Auction; as the old and new Auction may be very different, resulting in the user losing money.

For example:

  1. Alice learns about the auction in the UI, auctions = {type=LARGE_RISK_FUND,debt=100,seizedRiskFund=100} and submits it to participate in the auction.

  2. When Alice commits, her transaction will exist in memorypool.

    Note: Because Alice needs to stay in the UI interface for some time, or because of the GAS price and block size, Alice’s transaction is delayed, resulting in a much higher possibility of preemptive execution in step 3:

  3. The auction is restarted due to any of the following situations (before Alice’s task is executed):

    a) Auction >waitForFirstBidder leads to _isStale(). Bob executes restarted auction, restarted auction debt increases. E.g.: auction = {type=LARGE_POOL_DEBT,debt=100000,seizedRiskFund=100}.

    b) The auction ends >nextBidderBlockLimit. Bob restarts the auction, and the restarted auction seizedRiskFund becomes small, like 0, the debt is already very high as auction = {type=LARGE_POOL_DEBT,debt=100,seizedRiskFund=0}, there may also be still LARGE_RISK_FUND.

  4. Alice’s turn to execute the transaction, this time the new auction, and Alice expected has been much worse, but the transaction will still be executed. The result is that Alice may pay a lot of debt, but get very little seizedRiskFund.

So, we need to add a restriction to placeBid() to ensure that the auction has not been restarted when the transaction is executed.

A simple way to do this is to add the parameter: auctionStartBlock, and compare it to the auction.startBlock of the current transaction. If the two are different, then the auction has been restarted and the transaction reverts.

Recommended Mitigation Steps

-   function placeBid(address comptroller, uint256 bidBps) external nonReentrant {
+   function placeBid(address comptroller, uint256 bidBps , uint256 auctionStartBlock) external nonReentrant {
        Auction storage auction = auctions[comptroller];

+       require(auction.startBlock == auctionStartBlock,"auction has been restarted");
        require(_isStarted(auction), "no on-going auction");
        require(!_isStale(auction), "auction is stale, restart it");
        require(bidBps <= MAX_BPS, "basis points cannot be more than 10000");

Assessed type

Context

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

I don’t see this is as being a High, but do follow the wardens logic on why this could be problematic. Will downgrade to Medium and look forward to sponsor comment.

chechu (Venus) confirmed


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 placeBid function does not verify that the auction has not been restarted since the bid was submitted, because it only uses the comptroller address to identify the auction.

Impact

A user could pay a large debt but receive very little seized risk fund, resulting in a loss of funds.

What the attacker needed

User submits a bid transaction; auction is restarted before the bid is mined

The fix

The placeBid function should accept an auctionStartBlock parameter and revert if it does not match the current auction's start block, ensuring the auction has not been restarted.

How it was found

  1. Alice sees an auction in the UI and submits a bid transaction.
  2. Before Alice's transaction is mined, the auction is restarted due to staleness or end conditions.
  3. Alice's transaction executes against the new auction, which may have different terms, causing her to lose funds.

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.

An auction lets people bid on debt. The function that places a bid only uses the comptroller address to find the auction, not a unique auction identifier. If the auction is restarted before the bid is processed, the bid goes to the new auction, which may have very different terms, so the bidder can lose money.

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 Venus Prime

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.