The fulfillRequest function does not validate the requestId against the s_lastRequestId set in sendRequest.
The RAAC protocol retrieves the price of RAACHouse NFTs using a Chainlink function. The process follows these steps:
The Chainlink cron job calls RAACHousePriceOracle::sendRequest.
The sendRequest function sets s_lastRequestId.
The function then calls _beforeFulfill, as shown in the code below.
Chainlink than calls fulfillRequest to set the house price.
the _beforeFulfill sets the lastHouseId
The fulfillRequest receives the requestId and calls _processResponse.
The _processResponse sets the price against lastHouseId by calling RAACHousePrices::setHousePrice. and the protocol can call RAACHousePrices::getLatestPrice to get the latest price of RAAC House.
However fulfillRequest never confirms that the requestId it receives matches s_lastRequestId.
The cron job submits _sendRequest for NFTId 1 and sets s_lastRequestId = 0x1234.
This also sets lastHouseId = 1 in the _beforeFulfill function.
While the contract is waiting for fulfillRequest,
The cron job submits another _sendRequest for NFTId 2 and sets s_lastRequestId = 0x8976.
Now lastHouseId = 2. The Chainlink function calls fulfillRequest for NFTId = 1 with requestID = 0x1234.
In the _processResponse function, the price of lastHouseId = 2 is incorrectly set with the price of lastHouseId = 1.
This sequence of events leads to incorrect pricing for NFTs, resulting in a mismatch between requestId and lastHouseId.
Note : BaseChainlinkFunctionsOracle is not in direct scope , but the contract which will be effected by this issue are in scope.
A mismatch in requestId will result in an incorrect price being set for the lastHouseId. While the likelihood of this happening may be low, the impact is significant, as the wrong price will be associated with an NFT.
This issue qualifies as a medium severity vulnerability.
Manual Review
Include a check to ensure fulfillRequest uses the correct requestId as mentioned in the chainlink docs.
For example:
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.