Closed code423n4 closed 2 years ago
Dravee
SLOADs are expensive
Here, _lowerSlack[_target] can be loaded twice from storage:
_lowerSlack[_target]
307: function getLowerSlack(address _target) 308: external 309: view 310: override 311: returns (uint256) 312: { 313: if (_lowerSlack[_target] == 0) { 314: return _lowerSlack[address(0)]; 315: } else { 316: return _lowerSlack[_target]; 317: } 318: }
VS Code
Cache the storage reading in a memory variable
https://github.com/code-423n4/2022-01-insure-findings/issues/320
Handle
Dravee
Vulnerability details
Impact
SLOADs are expensive
Proof of Concept
Here,
_lowerSlack[_target]
can be loaded twice from storage:Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage reading in a memory variable