Users will wait untille the last day to cancel reservation to avoid cancellation penalty #36
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
primary issue
Highest quality submission among a set of duplicates
🤖_36_group
AI based duplicate group recommendation
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2024-10-coded-estate/blob/main/contracts/codedestate/src/execute.rs#L1082
Vulnerability details
Description
This protocol gives the right to homeowners to apply a penalty for cancellation after the rent gets approved
The logic is here in
execute.rs#cancelreservationafterapprovalforshortterm()
functionso the cancellation penalty depends on how many days are left before your rent starts.
It calculates the
diff_days
by subtracting the check-in time from the current time and dividing by86400
How ever in case the subtracting gives a number less than
86400
thediff_days
will be zeroand this check here
if item.deadline < diff_days {
will never be trueSo these two lines will set the
token.rentals[].cancelled
to true and keep thetoken.rentals[].deposit_amount
same as before because therefundable_amount
is zeroImpact
users will wait until the last day to cancel the reservation and withdraw all the initial deposit even with the existing of cancellation penalty.
Tools Used
Manual Review
Recommended Mitigation Steps
for (_i, item) in cancellation.iter().enumerate() { - if item.deadline < diff_days { + if item.deadline <= diff_days { refundable_amount = Uint128::new((amount.u128() * u128::from(item.percentage)) / 100); break; } }
Assessed type
Other
The text was updated successfully, but these errors were encountered: