Closed code423n4 closed 2 years ago
Dravee
SLOADs are expensive
Here, _maxList[_target] can be loaded twice from storage:
_maxList[_target]
397: function getMaxList(address _target) 398: external 399: view 400: override 401: returns (uint256) 402: { 403: if (_maxList[_target] == 0) { 404: return _maxList[address(0)]; 405: } else { 406: return _maxList[_target]; 407: } 408: }
VS Code
Cache the storage reading in a memory variable
https://github.com/code-423n4/2022-01-insure-findings/issues/320
dupe of #320
Handle
Dravee
Vulnerability details
Impact
SLOADs are expensive
Proof of Concept
Here,
_maxList[_target]
can be loaded twice from storage:Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage reading in a memory variable