Closed code423n4 closed 2 years ago
Dravee
SLOADs are expensive
Here, _upperSlack[_target] can be loaded twice from storage:
_upperSlack[_target]
289: function getUpperSlack(address _target) 290: external 291: view 292: override 293: returns (uint256) 294: { 295: if (_upperSlack[_target] == 0) { 296: return _upperSlack[address(0)]; 297: } else { 298: return _upperSlack[_target]; 299: } 300: }
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,
_upperSlack[_target]
can be loaded twice from storage:Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage reading in a memory variable