sherlock-audit/2024-04-xkeeper-judging

Check `_callers[_i]` before adding it to `_approvedCallers`

Closed this issue · 0 comments

Check _callers[_i] before adding it to _approvedCallers

Low/Info issue submitted by Naman

Summary:

In function AutomationVault::modifyRelay, while adding new callers to the _approvedCallers we must check the address before adding it to the mapping to avoid unnecessary data. This is resolved in AutomationVault::modifyRelayJobs where _jobData.job is checked using simple logic

Vulnerability Detail:

In functions modifyRelay, we change the internal mapping of contract, to avoid unnecessary data collection we can use simple address check.

Impact

This will lead to unnecessary data collection and gas ineffiency

Code Snippet

function modifyRelayCallers(address _relay, address[] memory _callers) public onlyOwner {
(+) if(_callers[i] == address(0)) revert CustomError();    
      if (_approvedCallers[_relay].add(_callers[_i])) {
        emit ApproveRelayCaller(_relay, _callers[_i]);
      }
  }

Tool used

Manual Review

Recommendation:

Use require(_callers[i]!=0) or if-statement along with a custom error to handle this