HardhatDeFi
15,000 USDC
View results
Submission Details
Severity: medium
Invalid

nonreentrant modiifier should occur before all other modifiers

Summary:

In (contracts/src/AaveDIVAWrapper.sol#23#85#102#1991

LINE NUMBER 23 CODE:

) external override onlyOwner nonReentrant returns (address) {

LINE NUMBER 85 CODE:

) external override onlyOwner nonReentrant returns (uint256) {

LINE NUMBER 102 CODE:

) external override onlyOwner nonReentrant returns (address[] memory) {

LINE NUMBER 1991 CODE:

) external override onlyOwner nonReentrant returns (uint256[] memory) {

The vulnerability arises from the order of modifiers applied to the registerCollateralToken and claimYield functions. In Solidity, the order of modifiers can affect the execution flow and security of a function. The nonReentrant modifier is designed to prevent reentrancy attacks by ensuring that a function cannot be called again until it has completed its execution. However, if the nonReentrant modifier is not the first modifier applied, there is a risk that other modifiers, such as onlyOwner, could execute code that might inadvertently allow reentrancy vulnerabilities to be exploited before the nonReentrant check is enforced. To mitigate this risk, the nonReentrant modifier should be placed before all other modifiers to ensure that the reentrancy protection is applied as early as possible in the function execution.

Vulnerability Details

Impact

Tools Used

Recommendations:

To resolve the issue, reorder the modifiers in the registerCollateralToken and claimYield functions so that the nonReentrant modifier is applied before the onlyOwner modifier. This ensures that the reentrancy protection is enforced at the earliest point in the function execution. Here is the recommended change:

function registerCollateralToken(
address _collateralToken
) external override nonReentrant onlyOwner returns (address) {
return _registerCollateralToken(_collateralToken);
}
function claimYield(
address _collateralToken,
address _recipient
) external override nonReentrant onlyOwner returns (uint256) {
return _claimYield(_collateralToken, _recipient);
}

By making this change, you ensure that the nonReentrant protection is applied before any other logic, reducing the risk of reentrancy vulnerabilities.

Updates

Lead Judging Commences

bube Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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