Mismatched token and price feed addresses in the constructor of the DSCEngine contract can lead to incorrect price valuations and potential financial risks. The code assumes that the addresses at the same index in both arrays represent valid pairs of tokens and their corresponding price feeds. If the arrays are not aligned correctly, it can create vulnerabilities.
The vulnerability lies in the constructor of the DSCEngine contract. Specifically, in the code block that populates the s_priceFeeds
mapping and the s_collateralTokens
array with token addresses and their corresponding price feed addresses. If there is a mismatch between the addresses at the same index in the tokenAddresses
and priceFeedAddresses
arrays, the contract will consider them as valid pairs, leading to incorrect price valuations.
The potential impact of this vulnerability includes the following:
Incorrect Price Valuations: Mismatched price feeds can lead to incorrect valuations of tokens, causing instability in the stable coin's value.
Loss of Funds: Users might be able to manipulate the contract and trade assets at incorrect valuations, leading to potential losses for other users.
Arbitrage Opportunities: Mismatched price feeds can create arbitrage opportunities for malicious actors to manipulate token prices and exploit the contract for their gain.
Manual code review and analysis.
To address this vulnerability, it is essential to ensure that the tokenAddresses
and priceFeedAddresses
arrays are correctly aligned during contract deployment. One possible way to do this is by adding additional validation checks in the constructor.
By adding validation, you can prevent the vulnerability and ensure that the DSCEngine contract works as intended with accurate price valuations.
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.