https://github.com/CodeHawks-Contests/2025-03-inheritable-smart-contract-wallet/blob/main/src/InheritanceManager.sol#L143-L147
The createEstateNFT function in the InheritanceManager contract has a critical vulnerability where the assetToPay state variable is overwritten every time a new Estate NFT is created. This means only the most recently specified asset address will be considered valid for all Estate NFTs, rendering the intended per-NFT asset payment scheme ineffective and leading to potential loss of funds or unintended asset transfers.
createEstateNFT FunctionDescription: This function allows the owner to create an NFT representing an underlying asset (like real estate). When an NFT is created, the owner specifies a _description, _value, and _asset.
Issue: The assetToPay state variable is overwritten with each new NFT creation, as shown in this line:
The assetToPay state variable is declared as a single address.
This variable is updated with _asset each time createEstateNFT is called.
There is no mapping or array to store multiple assetToPay addresses corresponding to different NFTs.
buyOutEstateNFT FunctionDescription: This function uses assetToPay to determine the payment asset for buying out an Estate NFT.
Issue: The function relies on the assetToPay state variable, which only reflects the most recently set asset:
This means that only the last assetToPay will be used, regardless of the NFT being bought out.
When beneficiaries attempt to buy out an Estate NFT using the buyOutEstateNFT function, they will always be required to pay in the _asset that was specified for the last NFT created.
If different NFTs are intended to be paid with different assets, beneficiaries could send funds to the wrong asset if they're not aware of this flaw. The owner could also get confused, causing a significant loss of funds.
Beneficiaries may buy an NFT with a different asset than intended.
Manual Code Review
assetToPayChange assetToPay from a single address to a mapping that associates NFT IDs with payment asset addresses.
createEstateNFTModify createEstateNFT to store the _asset in the mapping, using the nftID as the key.
buyOutEstateNFTModify buyOutEstateNFT to retrieve the correct asset address from the mapping.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.