None
EN
Numbers turned weapons: DoS in Osmosis’ math library
['Sam Alws']
The Trail of Bits Blog
Trail of Bits is publicly disclosing a vulnerability in the Osmosis chain that allows an attacker to craft a transaction that takes up a disproportionate amount of compute time on Osmosis nodes compared to the amount of gas it consumes. // calculate a^b // assumption: a is between 0 and 2, b is between 0 and 1 fn PowApprox(a,b) { total <- 1 i <- 0 term <- 1 const precision = 0.00000001 // (the real implementation took precision as a function parameter rather than a constant) while abs(term) >= precision { i <- i + 1 term <- term * ((b-(i-1)) / i) * (a-1) total <- total + term } return total } There is a call to PowApprox in the following piece of code, used in Osmosis to calculate the amount of shares to give when someone deposits tokens into a swap pool: