code-423n4 / 2021-09-wildcredit-findings

0 stars 0 forks source link

Reordering state variable declarations to prevent incorrect packing can save slots/gas #91

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago

Handle

0xRajeev

Vulnerability details

Impact

The bool initialized gets packed with address variable underlying (boolean is internally uint8 and address is 20 bytes, both of which fit in a 32B slot) and requires extra bytecode for masking whenever underlying is used while initialized is used rarely and only inside the initialize() function.

Proof of Concept

https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/LPTokenMaster.sol#L21-L25

Tools Used

Manual Analysis

Recommended Mitigation Steps

Move declaration of bool initialized to after string symbol.