Summary: In some conditions, variables can overwrite different variables in storage.
Affected variations of the Solidity compiler: 0.1.6 to 0.4.3 (together with variations previous to the 0.4.4 launch)
Detailed description:
Storage variables which can be lower than 256 bits are packed collectively in the identical 256-bit slot if they will match. If the primary variable is assigned a worth bigger than the kind permits, that worth will overwrite the second variable.
Which means if an attacker could cause the primary variable to exceed its worth, then the second variable may be modified. Creating an overflow within the first variable is feasible through the use of arithmetic or immediately passing the worth from the decision information (values within the name information are 32-byte aligned, and padding is neither checked nor enforced).
Contracts that use solely the kinds listed beneath for state variables not affected. Arrays, mappings, and structs (based mostly on the next sorts) are too not affected by:
- signed integers, together with sizes lower than 256 bits
- of kind bytesNN, together with sizes lower than 256 bits
- unsigned integers (uint) of 256 bits
Contracts with sorts smaller than 256 bits which can be by no means subsequent to one another (notice that the state variables of base contracts are “indented”) are not affected.
Ethereum multisignature pockets contract is not affected. Observe that addresses take up 160 bits, so contracts utilizing solely addresses and 256-bit sorts are secure. Moreover, addresses and Booleans are nearly by no means manipulated through arithmetic operations in observe, so contracts utilizing solely addresses, Booleans, and 256-bit sorts also needs to be secure.
The next contracts could also be affected: Contracts containing two or extra consecutive state variables the place the sum of their sizes is lower than 256 bits, and the primary state variable shouldn’t be a signed integer and isn’t of kind bytesNN.
Sorts smaller than 256 bits embody: bool, enums, uint8, …, uint248, int8, …, int248, deal with, any kind of contract
Advisable motion:
- Recompile contracts that haven’t but been carried out utilizing a minimum of Solidity launch 0.4.4 (not a pre-release or nightly model).
- Deactivate, take away funds from, or improve already deployed contracts.
He discovered this vulnerability [github.com/catageek](https://github.com/catageek): [https://github.com/ethereum/solidity/issues/1306](https://github.com/ethereum/solidity/points/1306)