finalizelongtermrental()
refunds money to the token owner/ property manager instead of the tenant
#44
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
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-26
🤖_primary
AI based primary recommendation
🤖_25_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Lines of code
https://github.com/code-423n4/2024-10-coded-estate/blob/97efb35fd3734676f33598e6dff70119e41c7032/contracts/codedestate/src/execute.rs#L1728
Vulnerability details
Impact
finalizelongtermrental()
sends money to the token owner/ property manager instead of the tenant when the rental reservation has been cancelled.Proof Of Concept
https://github.com/code-423n4/2024-10-coded-estate/blob/97efb35fd3734676f33598e6dff70119e41c7032/contracts/codedestate/src/execute.rs#L1727-L1731
finalizelongtermrental()
iterates through thetoken.rentals
array to find a specific rental. If this rental was cancelled by the tenant or token owner, the deposit_amount which is the rent should be refunded back to the tenant, the address which provided the rent amount/made reservation in the first place. But in the logic above, ifitem.cancelled == true
, target is set to the token owner, the token owner is the manager/landlord of the rental property. This means that even if a reservation is cancelled, thedeposit_amount
still goes to the token owner.item.cancelled
is set to true incancelreservationafterapprovalforlongterm()
.So if tenant makes reservation via
setreservationforlongterm()
and then proceeds to cancel after approval viacancelreservationafterapprovalforlongterm()
, the deposit_amount which can be rent paid will not be refunded to the tenant whenfinalizelongtermrental()
is called. It will go to the token owner.The correct logic should be that if reservation item is marked cancelled, deposit amount should be refunded to tenant. If not marked cancelled then the deposit amount can go to token owner.
Reservation is cancelled, no value is provided but the no refund for the tenant who payed rent.
Recommened Mitigation
if
item.cancelled == true
make the target to be the tenant oritem.address
Assessed type
Context
The text was updated successfully, but these errors were encountered: