Handle
Dravee
Vulnerability details
Impact
A division by 2 can be calculated by shifting one to the right.
While the DIV opcode uses 5 gas, the SHR opcode only uses 3 gas. Furthermore, Solidity's division operation also includes a division-by-0 prevention which is bypassed using shifting.
POC
Instances include:
contracts\XOLE.sol:230: uint center = upper - (upper - lower) / 2;
contracts\XOLE.sol:418: uint32 center = upper - (upper - lower) / 2;
Tools Used
VS Code
Recommended Mitigation Steps
Replace / 2 with >> 1
Handle
Dravee
Vulnerability details
Impact
A division by 2 can be calculated by shifting one to the right.
While the
DIVopcode uses 5 gas, theSHRopcode only uses 3 gas. Furthermore, Solidity's division operation also includes a division-by-0 prevention which is bypassed using shifting.POC
Instances include:
Tools Used
VS Code
Recommended Mitigation Steps
Replace
/ 2with>> 1