Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 1.48 KB

Use of undefined behavior in equality check.md

File metadata and controls

33 lines (26 loc) · 1.48 KB

On the left-hand side of the equality check, there is an assignment of the variable outputAmt_.

The right-hand side uses the same variable.

The Solidity 0.7.3. documentation states that “The evaluation order of expressions is not specified (more formally, the order in which the children of one node in the expression tree are evaluated is not specified, but they are of course evaluated before the node itself).

It is only guaranteed that statements are executed in order and short-circuiting for boolean expressions is done” which means that this check constitutes an instance of undefined behavior.

As such, the behavior of this code is not specified and could change in a future release of Solidity.

Recommendation:

Short term, rewrite the if statement such that it does not use and assign the same variable in an equality check. Long term, ensure that the codebase does not contain undefined Solidity or EVM behavior.


Slide Screenshot

055.jpg


Slide Text

  • ToB Audit DFX Finding 10
  • Undefined Behavior
  • High Severity
  • Variable Assign & Use
  • LHS & RHS Check
  • Rewrite Expression
  • Avoid Undefined Behavior

References


Tags