Informations de base
There are three major ways to store real numbers in computers. Each method is described along with the limitations of how they store their numbers.
- Fixed: Some implementations use a fixed number of binary bits to represent both the integer and the fraction. In the demonstrative example about Muller's Recurrence, the fraction 108.0 - ((815.0 - 1500.0 / z) / y) cannot be represented in 8 binary digits. The numeric accuracy within languages such as PL/1, COBOL and Ada is expressed in decimal digits rather than binary digits. In SQL and most databases, the length of the integer and the fraction are specified by the programmer in decimal. In the language C, fixed reals are implemented according to ISO/IEC TR18037
- Floating: The number is stored in a version of scientific notation with a fixed length for the base and the significand. This allows flexibility for more accuracy when the integer portion is smaller. When dealing with large integers, the fractional accuracy is less. Languages such as PL/1, COBOL and Ada set the accuracy by decimal digit representation rather than using binary digits. Python also implements decimal floating-point numbers using the IEEE 754-2008 encoding method.
- Ratio: The number is stored as the ratio of two integers. These integers also have their limits. These integers can be stored in a fixed number of bits or in a vector of digits. While the vector of digits method provides for very large integers, they cannot truly represent a repeating or transcendental number as those numbers do not ever have a fixed length.
Modes d'introduction
Implementation : This weakness is introduced when the developer picks a method to represent a real number. The weakness may only be visible with very specific numeric inputs.
Plateformes applicables
Langue
Class: Not Language-Specific (Undetermined)
Systèmes d’exploitation
Class: Not OS-Specific (Undetermined)
Architectures
Class: Not Architecture-Specific (Undetermined)
Technologies
Class: Not Technology-Specific (Undetermined)
Conséquences courantes
Portée |
Impact |
Probabilité |
Availability | DoS: Crash, Exit, or Restart
Note: 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. | |
Integrity | Execute Unauthorized Code or Commands
Note: 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. | |
Confidentiality Availability Access Control | Read Application Data, Modify Application Data
Note: 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. | |
Exemples observés
Références |
Description |
| Chain: series of floating-point precision errors
(CWE-1339) in a web browser rendering engine causes out-of-bounds read
(CWE-125), giving access to cross-origin data |
| Chain: rounding error in floating-point calculations
(CWE-1339) in image processor leads to infinite loop (CWE-835) |
| Chain: machine-learning product can have a heap-based
buffer overflow (CWE-122) when some integer-oriented bounds are
calculated by using ceiling() and floor() on floating point values
(CWE-1339) |
| Chain: insufficient precision (CWE-1339) in
random-number generator causes some zero bits to be reliably
generated, reducing the amount of entropy (CWE-331) |
| Chain: web browser crashes due to infinite loop - "bad
looping logic [that relies on] floating point math [CWE-1339] to exit
the loop [CWE-835]" |
Mesures d’atténuation potentielles
Phases : Implementation // Patching 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.
Notes de cartographie des vulnérabilités
Justification : This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Commentaire : Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.
Références
REF-1186
Is COBOL holding you hostage with Math?
https://medium.com/the-technical-archaeologist/is-cobol-holding-you-hostage-with-math-5498c0eb428b REF-1187
Intermediate results and arithmetic precision
https://www.ibm.com/docs/en/cobol-zos/6.2?topic=appendixes-intermediate-results-arithmetic-precision REF-1188
8.1.2. Arbitrary Precision Numbers
https://www.postgresql.org/docs/8.3/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL REF-1189
Muller's Recurrence
https://scipython.com/blog/mullers-recurrence/ REF-1190
An Improvement To Floating Point Numbers
https://hackaday.com/2015/10/22/an-improvement-to-floating-point-numbers/ REF-1191
HIGH PERFORMANCE COMPUTING: ARE WE JUST GETTING WRONG ANSWERS FASTER?
https://www3.nd.edu/~markst/cast-award-speech.pdf
Soumission
Nom |
Organisation |
Date |
Date de publication |
Version |
CWE Content Team |
MITRE |
2021-07-08 +00:00 |
2021-07-20 +00:00 |
4.5 |
Modifications
Nom |
Organisation |
Date |
Commentaire |
CWE Content Team |
MITRE |
2022-10-13 +00:00 |
updated Demonstrative_Examples |
CWE Content Team |
MITRE |
2023-01-31 +00:00 |
updated Common_Consequences, Description, Potential_Mitigations |
CWE Content Team |
MITRE |
2023-04-27 +00:00 |
updated References, Relationships |
CWE Content Team |
MITRE |
2023-06-29 +00:00 |
updated Mapping_Notes |
CWE Content Team |
MITRE |
2024-02-29 +00:00 |
updated Demonstrative_Examples |
CWE Content Team |
MITRE |
2025-04-03 +00:00 |
updated Demonstrative_Examples |