Attacker can drain all the funds in this contract #33
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-5
🤖_03_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Lines of code
https://github.com/code-423n4/2024-10-coded-estate/blob/main/contracts/codedestate/src/execute.rs#L708
Vulnerability details
Description
Every NFT has this
pub sell: Sell
field in itsTokenInfo
struct which is for selling NFTsThis contract is used by multiple homeowners which means it holds the funds (from the reservation and bid) for all the NFT in one place.
NFT owner can update the
pub sell: Sell
values by triggeringexecute.rs#setlistforsell()
Due to the lack of checking the current state of the NFT in this function address with permissions can update the values at any time.
Malicious users can take this advantage to steal all the funds (native token NIBI + all tokens from IBC ) by:
1- Mint NFT and set it for sell, set the
token.sell.denom
to IBC token that has a dust value in the market2- Then call
setbidtobuy()
function to setoffer:info.funds[0].amount
this amount will stay in the smart contract3- Now, re-set
token.sell.denom
(by invokingsetlistforsell()
) to a token that has more value (or even fewer decimals)4- Back to
setbidtobuy()
call it, this will lead to draining all the funds (of the specific token) in this cw721 smart contractthis happens because this message takes
denom
from the selldenom: token.sell.denom
which can be changed at any time.Impact
An attacker can drain all the funds in this contract
Manual Review
Recommended Mitigation Steps
Do not allow to update
denom
ifpub bids: Vec<Bid>
is not emptyAssessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: