The recent release version 0.4.25 of Solidity rectifies
two significant issues.
Another major issue was already resolved in version 0.4.22, although the existence of the bug was only recently recognized.
Please be aware that the Ethereum Foundation administers a bounty initiative related to the code generation aspect of Solidity.
Cleaning Up Exponent in Exponentiation
- Probability of occurrence: very minimal
- Potential for exploitation: high
- Detection through tests: low
- Resolved in version: 0.4.25
Overview: Utilizing shorter types in the exponent of an exponentiation operation may result in erroneous outcomes.
The Solidity programming language permits integer types that are less than 256 bits, even though the Ethereum Virtual Machine only recognizes types that are precisely 256 bits. Consequently, higher order bits must occasionally be set to zero.
For many operations, it does not matter whether those higher bits are zeroed out (an example being addition).
Therefore, to conserve gas, the Solidity compiler postpones this cleanup until necessary.
In the rare scenario where the exponent of the ** operator possesses a type shorter
than 256 bits, but not shorter than the base type, and contains unclean higher order bits,
this might yield an erroneous result. It is worth noting that literal exponents such as in x ** 2 and cases where the base type is
uint256 or int256 remain unaffected.
It is important to mention that a function parameter may carry unclean higher order bits if invoked by a malicious source,
and the same applies to data retrieved from the functions of contracts created by such entities.
Following an examination of numerous contracts, we believe this flaw affects only a very small fraction of
smart contracts, if any, since the typical uses of the exponentiation operator do not trigger the issue.
This issue was identified by nweller.
Memory Corruption in Multi-Dimensional Array Decoder
- Probability of occurrence: low
- Exploitability: moderate
- Detection through tests: high
- Introduced in version: 0.1.4
- Resolved in version: 0.4.22
Overview: Invoking functions from other contracts that return multi-dimensional fixed-size arrays leads to memory corruption.
When Solidity code calls a function that returns a multi-dimensional fixed-size array,
the returned ABI-encoded data must be converted to Solidity’s internal representation
of arrays. In Solidity, multi-dimensional arrays are managed as arrays of
memory pointers, whereas in the ABI, the data is encoded inline.
The decoder overlooked this distinction, resulting in the returned
elements being interpreted as memory pointers and thus leading to memory
corruption when accessing the return values. Function calls with multi-dimensional
fixed-size array arguments remain unaffected, as does returning fixed-size arrays from function calls
if they are outside a Solidity contract.
The flaw lies solely in the component responsible for decoding a multi-dimensional fixed-size array
returned from a function call within Solidity.
This issue was discovered by jmahhh.
Invalid Encoding of Structs in Events
- Probability of occurrence: low
- Exploitability: low
- Detection through tests: high
- Introduced in version: 0.4.17
- Resolved in version: 0.4.25
Overview: Structs used as event parameters are not managed correctly.
Structs were not intended to be supported as event parameters without the updated ABI encoder.
Despite this, the compiler accepted them, encoding their memory address instead of their actual value.
Even with the new ABI encoder, structs cannot be indexed in event parameters.
Currently, structs are appropriately prohibited for the old encoder and, if indexed, also for the new encoder.