This vulnerability occurs when a program uses a data type or algorithm that cannot accurately represent or calculate the fractional part of a real number, leading to incorrect results in security-critical operations.
Many security decisions, like financial transactions or cryptographic calculations, depend on extreme numerical precision. When a system uses floating-point arithmetic or other imprecise representations for these tasks, tiny rounding errors can create exploitable gaps. Attackers can manipulate these inaccuracies to trigger incorrect authorization, cause financial loss, or corrupt data. Computers fundamentally struggle to store certain fractional values exactly. Issues arise from finite storage (like limited bits in a float), repeating decimals in binary (like 0.1), or irrational numbers (like pi). The chosen representation may truncate or round the number, causing the program's internal calculation to drift from the mathematically correct result. Developers must therefore select numeric types and libraries that guarantee the required precision for their specific domain.
Impact: DoS: Crash, Exit, or Restart
This weakness will generally lead to undefined results and therefore crashes. In some implementations the program will halt if the weakness causes an overflow during a calculation.
Impact: Execute Unauthorized Code or Commands
The results of the math are not as expected. This could cause issues where a value would not be properly calculated and provide an incorrect answer.
Impact: Read Application DataModify Application Data
This weakness can sometimes trigger buffer overflows which can be used to execute arbitrary code. This is usually outside the scope of a product's implicit security policy.
fn rec_float(y: f64, z: f64) -> f64 {
rustUse num_rational::BigRational;
fn rec_big(y: BigRational, z: BigRational) -> BigRational {
rust