minRentalDayDivisor can be different between markets and treasury
The minimum rental day divisor can be updated in the treasury but not in already deployed markets, causing the treasury and markets to use different values. This could lead to unexpected results when calculating minimum rent time.
Submitted by gpersoon, also found by maplesyrup (heiho1 and thisguy__) and paulius.eth
The minRentalDayDivisor is defined in RCTreasury.sol and copied to each market. The minRentalDayDivisor can be updated via setMinRental, but then it isn’t updated in the already created market.
To calculate the minimum rent time, in function withdrawDeposit of RCTreasury.sol, the latest version of minRentalDayDivisor is used, which could be different than the values in the market. So the markets will calculate the minimum rent time different. This could lead to unexpected results
function initialize(
...
minRentalDayDivisor = treasury.minRentalDayDivisor();
https:
function withdrawDeposit(uint256 _amount, bool _localWithdrawal)
...
require( user[_msgSender].bidRate == 0 || block.timestamp - (user[_msgSender].lastRentalTime) > uint256(1 days) / minRentalDayDivisor, "Too soon");
..
if ( user[_msgSender].bidRate != 0 && user[_msgSender].bidRate / (minRentalDayDivisor) > user[_msgSender].deposit ) {
..
function setMinRental(uint256 _newDivisor) public override onlyOwner {
minRentalDayDivisor = _newDivisor;
}
Recommend either accepting or at least documenting the risk of change to code to prevent this from happening.
Splidge (Reality Cards) acknowledged:
Yes, This became apparent recently when we changed the
minRentalDayDivisorduring a beta test. Ideally this value is never changed and if it is changed then it will be done very infrequently. The main protectionminRentalDayDivisoroffers is against a DoS attack whereby an attacker gains some ownership time on a card and then will fill the orderbook with bids using sybil accounts (withdrawing almost all deposit after placing the bids), withoutminRentalDayDivisorthese low value (but legitimate) bids would prevent other users from gaining ownership of the card (due to gas limits there’s a limit to the rental collections we can perform) and give the attacker a greater share of the prize pot. The benefit ofminRentalDayDivisoris that now these are zero value bids which are eligible for immediate deletion, and so there is now more of a cost to the attack which scales with the cost of the rental prices (which will closely be linked to the value of the prize pot). To this endminRentalDayDivisoris at it’s most useful in the Treasury where it’s main purpose is fulfilled inwithdrawDeposit(), the usage in the markets is less beneficial and wasn’t considered worth the extra gas usage to have the Markets fetch the updated value given the infrequency we will be changing it. We have accepted this risk.
dmvt (Judge) upgraded severity from 1 to 2:
Updating to Medium risk to match the other reporting wardens: “Possible accidental loss of funds or information due to code manipulation or bad side effects of not properly outlining a payable function”
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 minRentalDayDivisor is stored separately in the treasury and each market, and updates to the treasury's value are not propagated to existing markets.
Impact
Markets and treasury may calculate minimum rent time differently, potentially leading to unexpected results such as users being able to withdraw too soon or being blocked incorrectly.
What the attacker needed
Owner changes minRentalDayDivisor; markets already deployed
The fix
The recommendation is to either accept or document the risk of changing the value, as the team has acknowledged and accepted the risk.
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.
A smart contract has a setting that controls how long someone must wait before withdrawing a deposit. The main contract can change this setting, but other contracts that copied the old value don't get updated. So they disagree on the waiting time, which could cause problems.
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.