15,000 USDC
View results
Submission Details
Severity: gas
Valid

nonReentrant modifier should come first

Summary

The nonReentrant modifier should occur before all other modifiers

Vulnerability Details

In DSCEngine.sol, the following is used

function redeemCollateral(address tokenCollateralAddress, uint256 amountCollateral)
public
moreThanZero(amountCollateral)
nonReentrant
{
_redeemCollateral(msg.sender, msg.sender, tokenCollateralAddress, amountCollateral);
_revertIfHealthFactorIsBroken(msg.sender);
}

Impact

The other modifiers could be re-entered if they have complex logic

Tools Used

Manual review

Recommendations

change the function to this.

function redeemCollateral(address tokenCollateralAddress, uint256 amountCollateral)
public
nonReentrant
moreThanZero(amountCollateral)
{
_redeemCollateral(msg.sender, msg.sender, tokenCollateralAddress, amountCollateral);
_revertIfHealthFactorIsBroken(msg.sender);
}

Support

FAQs

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