Closed code423n4 closed 2 years ago
Dravee
SLOADs are expensive
Here, _withdawable[_target] can be loaded twice from storage:
_withdawable[_target]
343: function getWithdrawable(address _target) 344: external 345: view 346: override 347: returns (uint256) 348: { 349: if (_withdawable[_target] == 0) { 350: return _withdawable[address(0)]; 351: } else { 352: return _withdawable[_target]; 353: } 354: }
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,
_withdawable[_target]
can be loaded twice from storage:Tools Used
VS Code
Recommended Mitigation Steps
Cache the storage reading in a memory variable