Flawed validation in short-term rental reservations allows overpayment #14
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
grade-a
primary issue
Highest quality submission among a set of duplicates
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_primary
AI based primary recommendation
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/main/contracts/codedestate/src/execute.rs#L860-L864
Vulnerability details
Impact
This bug allows renters to overpay for their short-term rental due to a flaw in the validation logic. The contract's price check does not prevent overpayment if the rental price changes between the time the renter sends the transaction and when it is executed. This can result in financial loss and an unintended overcharge for renters.
Description
The
setreservationforshortterm
function allows users to reserve a short-term rental by sending funds equal to or greater than the calculated rental price plus a protocol fee. However, there is a flaw in how the contract checks the deposited amount because the validation logic allows an overpayment.In a scenario where the renter sends a transaction with the intended price, and the property owner also try to lower the price before the renter's transaction is executed, the renter ends up paying more than the new rental price.
This behavior is problematic because the renter's intent is to pay the price at the moment they send the transaction. If the price changes during the transaction's pending period, the contract should revert the transaction to avoid unintended overpayment.
Code Snippet:
Example Scenario:
Rationale for severity
The severity is set to Medium because:
Proof-of-Concept
The following test demonstrate the described scenario.
Boilerplate for PoC: https://gist.github.com/nnez/c76b1a867dd8dc441dbe552e048b796e
Steps
contracts/codedestate/src/multi_tests.rs
with boilerplate from above secret gist.cargo test m1_reserve_the_same_block_as_update -- --nocapture
Recommended Mitigations
There are two available options:
Assessed type
Context
The text was updated successfully, but these errors were encountered: