2

Is Tezos vulnerable to overflow/ underflow attacks on the smart contracts? If yes, how do you recommend to test whether a particular smart contract suffers from it.

1 Answer 1

2

If you have two amounts (mutez): t1 and t2; t1 - t2 underflows when t2 is bigger than t1.

There is a similar overflow on mutez (they are 64 bits values).

Shifts are also problematic (LSL and LSR in Michelson).

When such an event happens, an exception is raised and that cancels the whole transaction.

Testing is not easy. For these cases, I personally think that they are a very good use case for automatic static analysis.

6
  • Why wouldn't testing be easy? If you set up a testing environment, you can call the contracts from a JavaScript environment and the calls to the contract should throw on overflows. Aug 3, 2020 at 8:17
  • If t1 - t2 becomes negative, it's still considered overflow. Underflow refers to floats becoming so small that they are rounded to 0. Aug 3, 2020 at 8:36
  • You call it what you wish. It’s called underflow in the tezos documentation that you may wish to read.
    – FFF
    Aug 3, 2020 at 14:56
  • In that case, that is an error in the documentation that should be fixed. It is a pretty bad idea for projects to start inventing their own definitions. Aug 3, 2020 at 15:22
  • 1
    They are fine except for shifts (LSL and LSR).
    – FFF
    Aug 5, 2020 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.