Insufficient Precision or Accuracy of a Real Number

Draft Base
Structure: Simple
Description

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.

Extended Description

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.

Common Consequences 3
Scope: Availability

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.

Scope: Integrity

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.

Scope: ConfidentialityAvailabilityAccess Control

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.

Potential Mitigations 1
Phase: ImplementationPatching and Maintenance
The developer or maintainer can move to a more accurate representation of real numbers. In extreme cases, the programmer can move to representations such as ratios of BigInts which can represent real numbers to extremely fine precision. The programmer can also use the concept of an Unum real. The memory and CPU tradeoffs of this change must be examined. Since floating point reals are used in many products and many locations, they are implemented in hardware and most format changes will cause the calculations to be moved into software resulting in slower products.
Demonstrative Examples 3
Muller's Recurrence is a series that is supposed to converge to the number 5. When running this series with the following code, different implementations of real numbers fail at specific iterations:

Code Example:

Bad
Rust

fn rec_float(y: f64, z: f64) -> f64 {

rust
The chart below shows values for different data structures in the rust language when Muller's recurrence is executed to 80 iterations. The data structure f64 is a 64 bit float. The data structures I<number>F<number> are fixed representations 128 bits in length that use the first number as the size of the integer and the second size as the size of the fraction (e.g. I16F112 uses 16 bits for the integer and 112 bits for the fraction). The data structure of Ratio comes in three different implementations: i32 uses a ratio of 32 bit signed integers, i64 uses a ratio of 64 bit signed integers and BigInt uses a ratio of signed integer with up to 2^32 digits of base 256. Notice how even with 112 bits of fractions or ratios of 64bit unsigned integers, this math still does not converge to an expected value of 5.

Code Example:

Good
Rust

Use num_rational::BigRational;

fn rec_big(y: BigRational, z: BigRational) -> BigRational {

rust
On February 25, 1991, during the eve of the Iraqi invasion of Saudi Arabia, a Scud missile fired from Iraqi positions hit a US Army barracks in Dhahran, Saudi Arabia. It miscalculated time and killed 28 people [REF-1190].
Sleipner A, an offshore drilling platform in the North Sea, was incorrectly constructed with an underestimate of 50% of strength in a critical cluster of buoyancy cells needed for construction. This led to a leak in buoyancy cells during lowering, causing a seismic event of 3.0 on the Richter Scale and about $700M loss [REF-1281].
Observed Examples 5
CVE-2018-16069Chain: series of floating-point precision errors (Insufficient Precision or Accuracy of a Real Number) in a web browser rendering engine causes out-of-bounds read (Out-of-bounds Read), giving access to cross-origin data
CVE-2017-7619Chain: rounding error in floating-point calculations (Insufficient Precision or Accuracy of a Real Number) in image processor leads to infinite loop (Loop with Unreachable Exit Condition ('Infinite Loop'))
CVE-2021-29529Chain: machine-learning product can have a heap-based buffer overflow (Heap-based Buffer Overflow) when some integer-oriented bounds are calculated by using ceiling() and floor() on floating point values (Insufficient Precision or Accuracy of a Real Number)
CVE-2008-2108Chain: insufficient precision (Insufficient Precision or Accuracy of a Real Number) in random-number generator causes some zero bits to be reliably generated, reducing the amount of entropy (Insufficient Entropy)
CVE-2006-6499Chain: web browser crashes due to infinite loop - "bad looping logic [that relies on] floating point math [Insufficient Precision or Accuracy of a Real Number] to exit the loop [Loop with Unreachable Exit Condition ('Infinite Loop')]"
References 6
Intermediate results and arithmetic precision
30-06-2021
ID: REF-1187
8.1.2. Arbitrary Precision Numbers
24-06-2021
ID: REF-1188
Muller's Recurrence
11-11-2017
ID: REF-1189
An Improvement To Floating Point Numbers
22-10-2015
ID: REF-1190
HIGH PERFORMANCE COMPUTING: ARE WE JUST GETTING WRONG ANSWERS FASTER?
23-06-1999
ID: REF-1191
Applicable Platforms
Languages:
Not Language-Specific : Undetermined
Technologies:
Not Technology-Specific : Undetermined
Modes of Introduction
Implementation