Weather Witness

First Flight #40
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: high
Likelihood: high
Invalid

Incorrect Recipient Address in _mint() Function

Root + Impact

Description

  • _mint() function in fulfillMintRequest() should mint a Weather NFT to the user's address

  • The current implementation mints a Weather NFT to msg.sender, which here in fulfillMintRequest() is Chainlink Functions Oracle

function fulfillMintRequest(bytes32 requestId) external {
bytes memory response = s_funcReqIdToMintFunctionReqResponse[requestId]
.response;
bytes memory err = s_funcReqIdToMintFunctionReqResponse[requestId].err;
require(
response.length > 0 || err.length > 0,
WeatherNft__Unauthorized()
);
if (response.length == 0 || err.length > 0) {
return;
}
UserMintRequest memory _userMintRequest = s_funcReqIdToUserMintReq[
requestId
];
uint8 weather = abi.decode(response, (uint8));
uint256 tokenId = s_tokenCounter;
s_tokenCounter++;
emit WeatherNFTMinted(requestId, msg.sender, Weather(weather));
_mint(msg.sender, tokenId); // @audit Nft is minted to msg.sender which here in fulfillMintRequest()
// is Chainlink Functions Oracle, and not to user's address
s_tokenIdToWeather[tokenId] = Weather(weather);
// ...Rest of code
}

Risk

Likelihood:

  • Reason 1 This happens everytime a request to mint a Weather NFT is made, by calling requestMintWeatherNFT

  • Reason 2 In response to the mint request Chainlink Functions calls fulfillMintRequest, which contains the _mint(msg.sender, tokenId) function, with incorrect NFT recipient


Impact:

  • Impact 1 NFT is not going to the user's account

  • Impact 2 Loss of funds associated with the mint price

Proof of Concept

Recommended Mitigation

Send NFT to _userMintRequest.user, instead of sending it to msg.sender.
Update event WeatherNFTMinted.

function fulfillMintRequest(bytes32 requestId) external {
bytes memory response = s_funcReqIdToMintFunctionReqResponse[requestId]
.response;
bytes memory err = s_funcReqIdToMintFunctionReqResponse[requestId].err;
require(
response.length > 0 || err.length > 0,
WeatherNft__Unauthorized()
);
if (response.length == 0 || err.length > 0) {
return;
}
UserMintRequest memory _userMintRequest = s_funcReqIdToUserMintReq[
requestId
];
uint8 weather = abi.decode(response, (uint8));
uint256 tokenId = s_tokenCounter;
s_tokenCounter++;
emit WeatherNFTMinted(requestId, _userMintRequest.user, Weather(weather)); + change
_mint(_userMintRequest.user, tokenId); + change
// and not to user; Should use _userMintRequest.user
s_tokenIdToWeather[tokenId] = Weather(weather);
// ...Rest of code
}
Updates

Appeal created

bube Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.