15,000 USDC
View results
Submission Details
Severity: medium

Add check to DSCEngine constructor to ensure that the array lengths are not zero, otherwise the contract will require redeployments

Summary

Add check to DSCEngine constructor to ensure that the array lengths are not zero, otherwise the contract will require redeployments

Vulnerability Details

If the contract gets created with empty array, then the whole coin will just be inoperable
as there will be no allowed token addresses for collateral.

112: constructor(address[] memory tokenAddresses, address[] memory priceFeedAddresses, address dscAddress) {

Link to code - https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/src/DSCEngine.sol#L112

Severity Justification

Marking this as medium as both the following medium criteria satisfy:

  • Disruption of protocol functionality or availability

Source: https://docs.codehawks.com/rewards-and-judging

Tools Used

Manual inspection

Recommendations

Consider adding length checks to the array in the constructor to ensure that its not 0,
or add a feature to add token addresses after the contract is initialized.

Support

FAQs

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