depositforlongtermrental()
does not validate the sent_amount
#25
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
edited-by-warden
primary issue
Highest quality submission among a set of duplicates
🤖_25_group
AI based duplicate group recommendation
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-10-coded-estate/blob/97efb35fd3734676f33598e6dff70119e41c7032/contracts/codedestate/src/execute.rs#L1544-L1590
Vulnerability details
Impact
depositforlongtermrental()
does not validate thesent_amount
. It doesn'tsetreservationforlongterm()
+depositforlongtermrental()
action.Proof Of Concept
https://github.com/code-423n4/2024-10-coded-estate/blob/97efb35fd3734676f33598e6dff70119e41c7032/contracts/codedestate/src/execute.rs#L1544-L1590
depositforlongtermrental()
is meant to be called aftersetreservationforlongterm()
by the tenant to make rent payment for the property to be rented. Each long term rental property's token struct has atoken.longterm_rental.price_per_month
value, this value is set by the token owner viasetlistforlongtermrental()
. Thistoken.longterm_rental.price_per_month
value in combination with therenting_period
ought to be used to calculate/validate if the amount sent in by the user is enough to cover the rent for the renting period.But this is not done here, this means the
depositforlongtermrental()
will allow a tenant to pay lesser than the minimum price to rent.info.funds[0].amount
is not checked to be equal to or greater thantoken.longterm_rental.price_per_month * renting_period[1] - renting_period[0] / (86400*30)
. Whererenting_period[1]
is the checkOut,renting_period[0]
is the checkIn and86400*30
represents a month in timestamp.Also, per logic in
setreservationforshortterm()
, the protocol collects fees from the traveller anytime a reservation is made. But sincesetreservationforlongterm()
handles no money and passes that responsibilty on todepositforlongtermrental()
,depositforlongtermrental
takes money but doesnt deduct or check that the amount sent in contains the rent + protocol fees charged for each reservation. There is no math for that.Recommened Mitigation
token.longterm_rental.price_per_month
value.Assessed type
Context
The text was updated successfully, but these errors were encountered: