smart-contracts icon indicating copy to clipboard operation
smart-contracts copied to clipboard

overflow possible in get Imbalance - very low likliehood.

Open ilanDoron opened this issue 6 years ago • 1 comments

In the getImbalance function, the multiplication totalImbalance *= resolution is performed unchecked. Since the resolution field can be arbitrarily big and totalImbalance can reach 2

63−1, overflows are possible.

A check on writing the resolution variable could be introduced to avoid this. Since the function is only used to retrieve information and in a benevolent case resolution should not be this big, this is unlikely. But because this function is used in the getRate function, a consequence could be returning a wrong rate to users. The same applies to currentBlockImbalance *= resolution.

ilanDoron avatar Jun 26 '18 08:06 ilanDoron

Adjusted in this PR https://github.com/KyberNetwork/smart-contracts/pull/422

manhlx3006 avatar Aug 30 '19 07:08 manhlx3006