Skip to content
Business logic Audit finding Intermediate

Missing call to removeOldBids may affect foreclosure

The withdrawDeposit function in the Treasury contract did not call removeOldBids, so closed market bids remained counted in the user's bidRate, potentially causing an incorrect foreclosure. An attacker could exploit this to cause a user to be foreclosed upon when they should not be.

0xRajeev Follow

Originally disclosed on Code4rena

Submitted by 0xRajeev

Orderbook.removeBids() as commented:

///remove bids in closed markets for a given user
///this can reduce the users `bidRate` and chance to foreclose

removeOldBids() is performed currently in Market.newRental() and Treasury.deposit() to “do some cleaning up, it might help cancel their foreclosure” as commented. However, this is missing in the withdrawDeposit() function where the need is the most because user is removing deposit which may lead to foreclosure and is even commented as being useful on L356.

The impact is that, if we do not remove closed market bids during withdrawDeposit, the closed market bids still get accounted in user’s bidRate in the conditional on L357 and therefore do not prevent the foreclosure in withdrawDeposit that may happen in L357-L367. User may get foreclosed because of mis-accounted closed-market bids in the order book.

Recommend adding call to removeOldBids() on L355 of withdrawDeposit() of Treasury.

Splidge (Reality Cards) confirmed but disagreed with severity and then resolved:

This was intentionally left out in an older version of the contracts because of the way withdrawDeposit worked before we had the per-user rent collection. Added it back in again here.

The original report as published on Code4rena, by 0xRajeev. 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 withdrawDeposit function failed to call removeOldBids before checking the user's bidRate, so closed market bids were still included in the calculation.

What the attacker needed

User has bids in closed markets; user calls withdrawDeposit

The fix

The fix was to add a call to removeOldBids in the withdrawDeposit function, which was done in a later commit.

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 smart contract, users place bids and deposits. If a user withdraws their deposit, the system checks if they still have enough funds to cover their bids. However, bids from closed markets were not being removed before this check, so the system thought the user had more bids than they actually did, which could wrongly trigger a foreclosure. This is like a bank counting old, cancelled checks when deciding if you have enough money, and then penalizing you for 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 0xRajeev

View all

61 more disclosed reports, best first.

More from Reality Cards (round 2)

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.