withdrawToLandlord() cant send all rent earned overtime to landlord #28
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
edited-by-warden
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary 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/97efb35fd3734676f33598e6dff70119e41c7032/contracts/codedestate/src/execute.rs#L1823-L1834
Vulnerability details
Impact
withdrawtolandlord()
function does not allow token.ower or any approved/operator address to withdraw all the earned rent to the provided landlord addressProof Of Concept
https://github.com/code-423n4/2024-10-coded-estate/blob/97efb35fd3734676f33598e6dff70119e41c7032/contracts/codedestate/src/execute.rs#L1823-L1834
The snippet above is from the iteration logic in
withdrawtolandlord()
. The inner if statement here does not allow the landlord to receive 100% of the rental value it has earned on the protocol.For example if a tennant has paid 10,000 USD over the span of 10 months and
price_per_month
is 1000 USD, the landlord wants to receive its 10,000 USD which is the total rent earned over time, the logic there will interpret to be:item.deposit_amount = 10,000
token.longterm_rental.price_per_month = 1000
amount = 10,000
10,000 - 1,000 = 9,000 is lower than 10,000 (the amount to be withdrawn) so this means the function will revert with
unavailableAmount
error. A months's rent will be stuck in the protocol and cannot be sent to the landlord.The validation for amount to be withdrawn to landlord is incorrect.
Recommened Mitigation
change the validation to be
Assessed type
Context
The text was updated successfully, but these errors were encountered: