# Logic flaw in check_can_edit_short allows editing short-term rental before finalization enabling theft of users' deposited funds

check_can_edit_short only checks checkout time, letting a landlord swap the rental denom to USDC before finalization and drain pooled deposits.

- Payout: Audit contest
- Severity: high
- Program: Coded Estate
- Found by: nnez
- Disclosed: 2024-12-04
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2024-10-coded-estate-findings/issues/4
- Library page: https://bugbountylibrary.com/r/c4%3A2024-10-coded-estate%3AH-07
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:access-control vuln:accounting-error vuln:business-logic

**Target:** CosmWasm short-term rental contract (setlistforshorttermrental / finalizeshorttermrental)
**Root cause:** check_can_edit_short permits editing the listing once the last rental's checkout time has passed, without verifying the rental was finalized or that no pending payment exists; finalizeshorttermrental then pays using the newly-set denom.
**Steps:**
1. Mint a token and call `SetListForShortTermRental` with a worthless denom (e.g. `useless-coin`), high price_per_day, auto_approve=true, minimum_stay=0.
2. As renter, call `SetReservationForShortTerm` on own listing with a past/1-second renting_period, depositing the worthless denom (e.g. 1000 useless-coin).
3. After checkout time passes, call `SetListForShortTermRental` again changing `denom` to USDC (check_can_edit_short passes since last_check_out_time < now).
4. Call `FinalizeShortTermRental` with the same renting_period; contract sends `amount` in the new USDC denom to the landlord.
5. Observe attacker USDC balance increased and contract USDC drained.
**How found:** Code review of finalizeshorttermrental showed it reads denom from the mutable shortterm_rental struct; tracing the setter setlistforshorttermrental revealed check_can_edit_short only compares checkout time to now rather than requiring finalization, exposing the window between checkout and finalize.
**Exploitation:** Attacker controls both landlord and renter accounts. They self-rent with a worthless token, wait until checkout, mutate the listing denom to a valuable token, then finalize so the contract pays out the rental amount in the valuable denom from pooled user deposits.
**Escalation:** Repeat across many tokens/rentals to drain the entire contract balance of valuable denoms.
**Insight:** When a payout function reads configuration (denom, price, recipient) from mutable state, audit every setter's guard for whether it accounts for unsettled obligations, not just time-based liveness; the gap between 'rental ended' and 'rental finalized' is the exploitable window.

