Reservations can be made outside of rental property’s available_period
The smart contract allows renters to make reservations for dates outside the property's declared available period because the reservation functions only check the minimum stay duration. An attacker could book a property for dates the owner did not intend to make available.
Submitted by adeolu
There is no check for if the renting_period is within the rentals available period (token.shortterm_rental.available_period). This means that reservations can be made to rent the property on dates outside its available period.
Proof Of Concept
Property managers/landlords can list a property via setlistforshorttermrental() and setlistforshorttermrental(). In both of these functions, the parameter available_period is accepted and is set into the rental token’s struct in storage as seen below:
pub fn setlistforshorttermrental(
.....
available_period: Vec<String>,
....
) -> Result<Response<C>, ContractError> {
......
token.shortterm_rental.available_period = available_period;
....
}
pub fn setlistforlongtermrental(
.....
available_period: Vec<String>,
....
) -> Result<Response<C>, ContractError> {
......
token.longterm_rental.available_period = available_period;
....
}
In these functions, the rental’s available time is specified by the property manager/owner and this is set into storage. But users can still make reservations for the property for times outside the rental’s available period. This is because setreservationforshortterm() and setreservationforlongterm() do not check that the renting_period specified by a renting user is within the rental property’s available_period. As seen below in both functions, they only check that the renting_period is more than the rental’s minimum stay duration, i.e., more than 1 day if minimum duration is 1 day. A real world scenario example of this bug is that a user can make still reservations for July 21-25th even though the property owner/manager has specified that the rental’s available period is only June 21-25th.
let new_checkout = renting_period[1].parse::<u64>();
let new_checkout_timestamp;
match new_checkout {
Ok(timestamp) => {
new_checkout_timestamp = timestamp;
}
Err(_e) => {
return Err(ContractError::NotReserved {});
}
}
if ((new_checkout_timestamp - new_checkin_timestamp)/ 86400) < token.shortterm_rental.minimum_stay {
return Err(ContractError::LessThanMinimum {});
}
let new_checkout = renting_period[1].parse::<u64>();
let new_checkout_timestamp;
match new_checkout {
Ok(timestamp) => {
new_checkout_timestamp = timestamp;
}
Err(_e) => {
return Err(ContractError::NotReserved {});
}
}
if ((new_checkout_timestamp - new_checkin_timestamp)/ 86400) < token.longterm_rental.minimum_stay {
return Err(ContractError::LessThanMinimum {});
}
Recommended Mitigation
Check that the renting_period specified by renting users is within the property’s available_period.
Assessed type
Context
blockchainstar12 (Coded Estate) acknowledged and commented:
It’s not necessary logic as owners can reject any request, available period is optional.
It’s not necessary logic as owners can reject any request, available period is optional.
But owners can set an
available_periodtime, with the idea that they expect renters to make reservations for that period only. Just because it’s optional doesn’t mean that when the feature is to be used it should not work as expected.
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 reservation functions omit a check that the requested renting period falls within the stored available period.
Impact
A renter could book a property for dates the owner did not make available, though the owner can reject the request.
What the attacker needed
A listed rental property with an available period set; ability to call the reservation function
The fix
The reservation functions should check that the requested renting period is within the property's available period.
How it was found
- A property manager lists a property for short-term or long-term rental and sets an available period.
- A user calls the reservation function with a renting period outside that available period.
- The contract only checks the minimum stay duration and accepts the reservation.
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 property owner can set which dates their rental is available. However, the code that handles booking requests does not check whether the requested dates fall within those available dates. So someone could book the property for a time the owner never opened up.
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.