15,000 USDC
View results
Submission Details
Severity: high

Flash loan attack is a possibility

Summary

An individual can borrow a large amount of assets without collateral, exploit price volatility, and then repay the loan within the same transaction, profiting from the manipulated changes in asset prices.

Vulnerability Detail

DSCEngine uses Chainlink oracles for pricing data, which are robust and less prone to manipulation due to their decentralized nature. However, even with decentralized price feeds, an attacker might still be able to manipulate prices in low-liquidity situations. Furthermore, the lack of safeguards for price volatility in DSCEngine presents additional risk, as the protocol may not be equipped to handle sudden and significant price swings.

For example:

  1. A user gets a large loan of ETH. This can be done through a flash loan service.

  2. They mint a large amount of DSC tokens by backing them with ETH using the function depositCollateralAndMintDsc().

  3. The act of minting a large amount of DSC tokens would theoretically increase the price of DSC since it follows the law of supply and demand. Usually, minting more tokens might not affect the price since the system will automatically adjust to maintain the peg. However, as the DSCEngine and dsc stablecoin gets introduced to the market, the liquidity will be low and volatility very high. This might cause a temporary price increase.

  4. If the price of DSC has increased, the user could potentially use the DSC to take out a larger loan of ETH, as the collateral value is higher. They could then repay the initial ETH loan and, if there's any surplus, they could keep it as profit.

Impact

If a flash loan attack were successful, the potential impact could be significant. The attacker could potentially profit from manipulated price discrepancies at the expense of other users, undermining the integrity of the platform and causing financial losses. Furthermore, the resulting loss of trust from the users could lead to a mass exit, further destabilizing the platform.

Tools Used

A detailed review of the code base was conducted to identify this issue.

Recommendation:

To guard against potential flash loan attacks, it is recommended that DSCEngine implement comprehensive security measures:

  1. Implement Volatility Safeguards: These measures could include circuit breakers that halt trading during extreme price volatility or mechanisms to limit the size of trades relative to the total liquidity available.

  2. Monitor For Unusual Activity: Regular monitoring can help to identify and halt potential attacks before they fully unfold.

  3. Implement some algorithmic logic to limit against extreme price movements.

Support

FAQs

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