RAACNFT::mint function does not validate that the house price retrieved from raac_hp.tokenToHousePrice(_tokenId) is denominated in 18 decimals. Since Chainlink Functions can only return values as arbitrary uint256 from the source configured by RAAC, the absence of this validation can lead to incorrect minting prices, potentially allowing users to mint NFTs at unintended lower prices.
RAACNFT::mint contains the following:
raac_hp.tokenToHousePrice(_tokenId) is a mapping from RAACHousePrices.sol that stores the latest prices set by the chainlink oracles. See the relevant function below:
RAAC uses chainlink functions to retrieve the latest house prices from the source they have configured and updates the tokenToHousePrice mapping as seen above. This can be seen in RAACHousePriceOracle.sol. The key function that does this is below:
RAACHousePriceOracle::_processResponse gets the response the RAAC source and calls RAACHousePrices::setHousePrice as described. There is no validation ensuring that price is denominated in 18 decimals. Unlike Chainlink Price Feeds, which have predefined decimal places for each asset, Chainlink Functions can return uint256 values that may have any arbitrary decimal precision depending on how the data source formats its response. With chainlink price feeds, whenever prices are received from the oracle, standard practice is to handle the decimal amounts and convert them to the required decimals. With chainlink functions, since prices are retrieved from RAAC source, it should follow the same behaviour to configure the decimals and prevent human error.
If the returned price has fewer decimals than expected which is very likely as human error can allow for a lack of precision. If such a situation occurs, the _amount check:
may allow the user to underpay for the NFT due to the incorrect price scale.
This test was run in RAACNFT.test.js in the "Minting" describe block
Financial Loss: Users may exploit incorrect pricing to mint NFTs for significantly less than intended.
NFT Devaluation: The house price is a core property of the NFT. If improperly set, the NFT may be rendered useless.
Potential Arbitrage: Users could mint NFTs at incorrect prices and resell them for profit.
Manual Review, Hardhat
Validate the Price Precision: Introduce a MINIMUM_PRICE_DECIMALS constant to enforce 18-decimal precision, ensuring that any incorrect price values are rejected.
Modify the mint function to include this check:
Normalize Price Based on Expected Decimals: Instead of assuming the price has 18 decimals, explicitly retrieve the expected decimal format from the Chainlink Functions response and normalize the price before comparison.
If the function is expected to return a uint256 with X decimals, manually scale it to 18 decimals before use:
This ensures that prices retrieved from Chainlink Functions are correctly scaled before use.
We need to assume that the trusted admin is able to properly configure the API that will provide values. As long as the response isn't empty (and there's a check for that) then anything else relies on the accuracy of the data the API provides.
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.