A user calls the WeatherNft.sol::requestMintWeatherNFT
function to start the minting process. At this time the user also pays the mint price. The weather data is requested from an oracle and once this is received, the user calls the WeatherNft.sol::fulfillMintRequest
function to mint the NFT.
The WeatherNft.sol::fulfillMintRequest
function does not check if the caller is the owner of the request. This means that anyone can call this function using the publicly readable request id and mint an NFT paid by some other user, effectively stealing their NFT.
The only check that is done is whether there is a response for the weather data request.
When the nft is minted, the msg.sender
is used as the owner of the NFT and not the original user who called the requestMintWeatherNFT
function.
Likelihood: High
It is very easy to listen to the events emitted by the requestMintWeatherNFT
function and get the requestId to use later to steal the NFT.
Impact: High
Anyone can mint an NFT paid by someone else. This can lead to a loss of funds for the original user and a loss of trust in the system.
This is a simple test where a user requests and pays for the minting of an NFT. The attacker listens to the events emitted by the requestMintWeatherNFT
function and gets the requestId. The attacker then calls the fulfillMintRequest
function with the stolen requestId and mints the NFT for themselves.
Two different solutions can be used to fix this issue:
Check the owner of the requestId: The fulfillMintRequest
function should check if the caller is the owner of the requestId before minting the NFT. This can be done by adding a check like this:
Use the original requestId: The fulfillMintRequest
function should use the original requestId to mint the NFT.
There is no check to ensure that the caller of the `fulfillMintRequest` function is actually the owner of the `requestId`. This allows a malicious user to receive a NFT that is payed from someone else.
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.