15,000 USDC
View results
Submission Details
Severity: high

Price Feed Misalignment Vulnerability in DSCEngine Contract

Summary:

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.

Vulnerability Details:

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.

Impact:

The potential impact of this vulnerability includes the following:

  1. Incorrect Price Valuations: Mismatched price feeds can lead to incorrect valuations of tokens, causing instability in the stable coin's value.

  2. Loss of Funds: Users might be able to manipulate the contract and trade assets at incorrect valuations, leading to potential losses for other users.

  3. Arbitrage Opportunities: Mismatched price feeds can create arbitrage opportunities for malicious actors to manipulate token prices and exploit the contract for their gain.

Tools Used:

Manual code review and analysis.

Recommendations:

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.

Support

FAQs

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