CWE-681 — Incorrect Conversion between Numeric Types
CWE-681: Incorrect Conversion between Numeric Types
MITRE CWE weakness
| Kind | Weakness |
| Abstraction | Base |
| Status | Draft |
| Likelihood of exploit | High |
Description
When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur.
Common consequences
- Other, Integrity: Unexpected State, Quality Degradation
Mitigations
Implementation — Avoid making conversion between numeric types. Always check for the allowed ranges.
References
- CWE page: https://cwe.mitre.org/data/definitions/681.html
- CWE list: https://cwe.mitre.org/data/index.html