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.

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.

| improve this answer | |
  • 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. – Thorkil Værge Aug 3 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. – Thorkil Værge Aug 3 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 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. – Thorkil Værge Aug 3 at 15:22
  • 1
    They are fine except for shifts (LSL and LSR). – FFF Aug 5 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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