Submitted by nnez, also found by Ch_301 (1, 2, 3)
https://github.com/code-423n4/2024-10-coded-estate/blob/main/contracts/codedestate/src/execute.rs#L1413
https://github.com/code-423n4/2024-10-coded-estate/blob/main/contracts/codedestate/src/execute.rs#L870
This vulnerability allows an attacker to exploit the lack of distinction between short-term and long-term rental types to withdraw funds in a different, more valuable token than the one initially used for payment, effectively steal other users funds deposited in the contract.
In the CodedEstate system, a property (token) can be listed for both short-term and long-term rentals, with each rental type having separate configurations; including the denomination (denom) of the token used for payments. The rental information for both types of rentals is stored in the same vector, rentals, and a rental_type flag is used within the Rental struct to differentiate between short-term (false) and long-term (true) rentals.
However, the contract does not make use of the rental_type flag in any function that handles rental operations. As a result, functions designated for short-term rentals can be used for long-term rentals, and vice versa, without proper validation of the rental type. This becomes problematic, especially since short-term and long-term rentals may use different denom tokens.
An attacker can exploit this by performing the following steps:
Supposed there are two legitimate tokens in on Nibiru chain (deployment chain), TokenX ~ $0.01 and USDC ~ $1.
This results in the attacker receiving a refund in the higher-value token, effectively stealing funds from other users who deposited USDC.
The following test demonstrates the described attacker scenario.
Boilerplate for PoC here.
Utilize rental_type flag to differentiate between short-term and long-term rental and enforce usage of functions according to its type.
Invalid Validation
blockchainstar12 (Coded Estate) confirmed
