The WeatherNft:requestMintWeatherNFT does not enforce the minimum amount needed for a successful registration on a Chainlink Node, meaning any amounts lower than the minimum will cause the fulfilMintRequest to revert when called and a user loosing funds.
The WeatherNFT:requestMintWeatherNFT is missing input validation on the _initLinkDeposit amount to make sure it is equal to or above the minimum Link required to successfully register on a Chainlink Node and request a dynamic NFT.
This missing input validation, is not apparent immediately as the function requestMintWeatherNFT executes successfully. However, when WeatherNFT:fulfillMintRequest is later called, it will fail, specifically when the Chainlink Function registerUpkeep is invoked.
This will result in the caller to loosing the initial funds sent in requestMintWeatherNFT due to there being no way to amend the value of _initLinkDeposit in the user struct, UserMintRequest.
As of testing in the current environment, the minimum value for _initLinkDeposit is 1e17; any lower value will cause the fufillMintRequest to fail. This is a cross-function issue as the missing input validation in requestMintWeatherNFT affects fufillMintRequest.
Affected Areas
The WeatherNFT:requestMintWeatherNFT
The WeatherNFT:fulfillMintRequest
The severity of the missing input validation is High due to
High Impact: there is a loss of funds attributed to the payable function requestMintWeatherNFT; once the _initLinkDeposit is set in the struct UserMintRequest it cannot be changed. This will result in a user having to resubmit a request for a Weather NFT at greater cost (as the price would have been increased - either by contract or another user).
High Likelihood: there are no additional requirements for the vulnerability to be triggered; only a value that is less than Chainlinks minimum funding requirement.
Manual Review
Foundry for PoC
To prove the validity of the issue, I have created a runnable PoC that proves the cross-function issue.
Description
A user calls WeatherNFT:requestMintWeatherNFT with registerKeeper as true and the value for _initLinkDeposit as 1e16.
The function executes successfully and the user is returned a RequestID.
The user then calls WeatherNFT:fulfillMintRequest with the returned RequestID
The interaction with a Chainlink Node will revert as the provided Link deposit is not enough to successful fund the node.
Code
Run with: forge test --mt testCrossFunctionBugFromMissingInputValidation --fork-url $AVAX_FUJI_RPC_URL --via-ir
A revert is expected, therefore the test passes.
In order to mitigate this issue, the _initLinkDesposit should be validated to make sure the first subscription passes.
Variable Declaration in
WeatherNftStore
Code Changes in
WeatherNft
Bonus: Flexibility
To account for any changes in Chainlink minimum requirement, a management function can also be added to alter the value of the minimum Link deposit required.
This is informational/invalid. If the LINK deposit is not enough, the function `registerUpkeep` will revert and it is responsibility of the user to provide the correct amount of `_initLinkDeposit`, if the user wants automated weather updates.
This is informational/invalid. If the LINK deposit is not enough, the function `registerUpkeep` will revert and it is responsibility of the user to provide the correct amount of `_initLinkDeposit`, if the user wants automated weather updates.
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.