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.
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
withdrawDepositworked before we had the per-user rent collection. Added it back in again here.
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.