Token owner can burn their token with active rental leading to renters' funds being stuck #2
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-09
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary recommendation
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2024-10-coded-estate/blob/main/contracts/codedestate/src/execute.rs#L523-L541
Vulnerability details
Impact
If the property owner calls the
burn
function while active rentals exist, the rental information, including deposits, is deleted. This prevents renters from retrieving their funds through the cancellation process, leading to funds of renters being stucked in the contract.Description
The
burn
function in the contract deletes all data associated with a token, including any active rental information.In the CodedEstate, renters must deposit funds in advance for short-term rentals, and this information is stored in a vector,
rentals
, linked to the token.The issue arises because the
burn
function only checks whether the caller is the owner or has approval to burn the token. It does not validate whether there are any active rentals associated with the token. As a result, if the property owner calls theburn
function while rentals are still active, all rental data, including the deposit amounts, is deleted from storage.Without the rental information, renters can no longer use the cancellation function to retrieve their deposits, as the contract does not retain any record of the rental. This leads to irreversible loss of funds for the renters.
Relevant code snippets
Example Scenario
burn
function to burn the token while rentals are still active.Proof-of-Concept
The following test demonstrate that the token owner can burn their token while there is active rental leading to renter's funds getting stuck in the contract.
Boilerplate for PoC: https://gist.github.com/nnez/c76b1a867dd8dc441dbe552e048b796e
Steps
contracts/codedestate/src/multi_tests.rs
with boilerplate from above secret gist.cargo test h1_burn_active_rental -- --nocapture
Recommended Mitigations
burn
function that there is no active rental.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: