The minting process for an NFT is split into two transactions: first, requestMintWeatherNFT initiates a Chainlink Functions request and takes payment, and second, fulfillMintRequest is intended to be called by the user after the Chainlink request is fulfilled to mint the NFT. However, the fulfillMintRequest function lacks proper access control. Anyone can call fulfillMintRequest with a valid _reqId once the Chainlink Functions response data is available on-chain, allowing an attacker to front-run the legitimate user and mint the NFT to their own address instead of the original requester's.
Likelihood: High
The Chainlink Functions fulfillment process makes the response data available on-chain via the handleOracleFulfillment (and subsequently fulfillRequest) callback, which is visible to anyone monitoring the blockchain.
An attacker can easily obtain the requestId from the WeatherNFTMintRequestSent event emitted by the requestMintWeatherNFT function call and monitor for the Chainlink fulfillment. Once fulfilled, they can call the unrestricted fulfillMintRequest function with the known requestId.
Impact: High
An attacker can steal the NFT that the legitimate user paid for and initiated the request for by calling fulfillMintRequest before the legitimate user.
The legitimate user suffers financial loss, having paid the mint price (and potentially a LINK deposit for keeper upkeep) but receiving no NFT. This also erodes user trust in the protocol.
The provided test case accurately demonstrates the vulnerability:
Add a check at the beginning of the fulfillMintRequest function to ensure that msg.sender is the same address as the user who initiated the request, retrieved from the s_funcReqIdToUserMintReq mapping.
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.