2132
if ( EOF == error ){
die("No integer passed: Die evil hacker!\n");
}
if ( m > MAX_DIM || n > MAX_DIM ) {
die("Value too large: Die evil hacker!\n");
}
board = (board_square_t*) malloc( m * n * sizeof(board_square_t));
...
While this code checks to make sure the user cannot specify large, positive integers and consume
too much memory, it does not check for negative values supplied by the user. As a result, an
attacker can perform a resource consumption (CWE-400) attack against this program by specifying
two, large negative values that will not overflow, resulting in a very large memory allocation
(CWE-789) and possibly a system crash. Alternatively, an attacker can provide very large negative
values which will cause an integer overflow (CWE-190) and unexpected behavior will follow
depending on how the values are treated in the remainder of the program.
Observed Examples
Reference Description
CVE-2022-21668 Chain: Python library does not limit the resources used to process images
that specify a very large number of bands (CWE-1284), leading to excessive
memory consumption (CWE-789) or an integer overflow (CWE-190).
https://www.cve.org/CVERecord?id=CVE-2022-21668
CVE-2008-1440 lack of validation of length field leads to infinite loop
https://www.cve.org/CVERecord?id=CVE-2008-1440
CVE-2008-2374 lack of validation of string length fields allows memory consumption or buffer
over-read
https://www.cve.org/CVERecord?id=CVE-2008-2374
MemberOf Relationships
This MemberOf relationships table shows additional CWE Catgeories and Views that reference this
weakness as a member. This information is often useful in understanding where a weakness fits
within the context of external information sources.
Nature Type ID Name Page
MemberOf 1406 Comprehensive Categorization: Improper Input
Validation
1400 2531
Notes
Maintenance
This entry is still under development and will continue to see updates and content improvements.
CWE-1285: Improper Validation of Specified Index, Position, or Offset in Input
Weakness ID : 1285
Structure : Simple
Abstraction : Base
Description
The product receives input that is expected to specify an index, position, or offset into an indexable
resource such as a buffer or file, but it does not validate or incorrectly validates that the specified
index/position/offset has the required properties.
Extended Description
Often, indexable resources such as memory buffers or files can be accessed using a specific
position, index, or offset, such as an index for an array or a position for a file. When untrusted input
CWE Version 4.14
CWE-1285: Improper Validation of Specified Index, Position, or Offset in Input
CWE-1285: Improper Validation of Specified Index, Position, or Offset in Input