CVE-2024-26969 - Improper Validation of Array Index

Severity

55%

Complexity

18%

Confidentiality

60%

In the Linux kernel, the following vulnerability has been resolved: clk: qcom: gcc-ipq8074: fix terminating of frequency table arrays The frequency table arrays are supposed to be terminated with an empty element. Add such entry to the end of the arrays where it is missing in order to avoid possible out-of-bound access when the table is traversed by functions like qcom_find_freq() or qcom_find_freq_floor(). Only compile tested.

CVSS 3.1 Base Score 5.5. CVSS Attack Vector: local. CVSS Attack Complexity: low. CVSS Vector: (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H).

Demo Examples

Improper Validation of Array Index

CWE-129

In the code snippet below, an untrusted integer value is used to reference an object in an array.


               
}
return array[index];

If index is outside of the range of the array, this may result in an ArrayIndexOutOfBounds Exception being raised.

Improper Validation of Array Index

CWE-129

The following example takes a user-supplied value to allocate an array of objects and then operates on the array.


               
}
list[0] = new Widget();
die("Negative value supplied for list size, die evil hacker!");

This example attempts to build a list from a user-specified value, and even checks to ensure a non-negative value is supplied. If, however, a 0 value is provided, the code will build an array of size 0 and then try to store a new Widget in the first location, causing an exception to be thrown.

Improper Validation of Array Index

CWE-129

In the following code, the method retrieves a value from an array at a specific array index location that is given as an input parameter to the method


               
}
return value;// check that the array index is less than the maximum// length of the array
value = array[index];// get the value at the specified index of the array
// if array index is invalid then output error message// and return value indicating error
value = -1;

However, this method only verifies that the given array index is less than the maximum length of the array but does not check for the minimum value (CWE-839). This will allow a negative value to be accepted as the input array index, which will result in a out of bounds read (CWE-125) and may allow access to sensitive memory. The input array index should be checked to verify that is within the maximum and minimum range required for the array (CWE-129). In this example the if statement should be modified to include a minimum range check, as shown below.


               
...// check that the array index is within the correct// range of values for the array

Improper Validation of Array Index

CWE-129

The following example retrieves the sizes of messages for a pop3 mail server. The message sizes are retrieved from a socket that returns in a buffer the message number and the message size, the message number (num) and size (size) are extracted from the buffer and the message size is placed into an array using the message number for the array index.


               
}/* capture the sizes of all messages */
// read values from socket and added to sizes array
// continue read from socket until buf only contains '.'
break;
sizes[num - 1] = size;
...

In this example the message number retrieved from the buffer could be a value that is outside the allowable range of indices for the array and could possibly be a negative number. Without proper validation of the value to be used for the array index an array overflow could occur and could potentially lead to unauthorized access to memory addresses and system crashes. The value of the array index should be validated to ensure that it is within the allowable range of indices for the array as in the following code.


               
}/* capture the sizes of all messages */
// read values from socket and added to sizes array
}// continue read from socket until buf only contains '.'
break;
sizes[num - 1] = size;
report(stderr, "Warning: ignoring bogus data for message sizes returned by server.\n");/* warn about possible attempt to induce buffer overflow */
...

Improper Validation of Array Index

CWE-129

In the following example the method displayProductSummary is called from a Web service servlet to retrieve product summary information for display to the user. The servlet obtains the integer value of the product number from the user and passes it to the displayProductSummary method. The displayProductSummary method passes the integer value of the product number to the getProductSummary method which obtains the product summary from the array object containing the project summaries using the integer value of the product number as the array index.


               
}// Method called from servlet to obtain product information
return productSummary;
String productSummary = getProductSummary(index);
return products[index];

In this example the integer value used as the array index that is provided by the user may be outside the allowable range of indices for the array which may provide unexpected results or cause the application to fail. The integer value used for the array index should be validated to ensure that it is within the allowable range of indices for the array as in the following code.


               
}// Method called from servlet to obtain product information
return productSummary;
String productSummary = getProductSummary(index);
return productSummary;
productSummary = products[index];
throw new IndexOutOfBoundsException();

An alternative in Java would be to use one of the collection objects such as ArrayList that will automatically generate an exception if an attempt is made to access an array index that is out of bounds.


               
} catch (IndexOutOfBoundsException ex) {...}
productSummary = (String) productArray.get(index);

Improper Validation of Array Index

CWE-129

The following example asks a user for an offset into an array to select an item.


               
}
printf("You selected %s\n", items[index-1]);

The programmer allows the user to specify which element in the list to select, however an attacker can provide an out-of-bounds offset, resulting in a buffer over-read (CWE-126).

Overview

First reported 9 months ago

2024-05-01 06:15:00

Last updated 2 months ago

2024-12-23 13:58:00

Affected Software

Linux Kernel

References

https://git.kernel.org/stable/c/e117c6e2d1617520f5f7d7f6f6b395f01d8b5a27

https://git.kernel.org/stable/c/83fe1bbd9e259ad109827ccfbfc2488e0dea8e94

https://git.kernel.org/stable/c/851cc19bdb02556fb13629b3e4fef6f2bdb038fe

https://git.kernel.org/stable/c/9de184d4e557d550fb0b7b833b676bda4f269e4f

https://git.kernel.org/stable/c/dd92b159c506804ac57adf3742d9728298bb1255

https://git.kernel.org/stable/c/b6b31b4c67ea6bd9222e5b73b330554c57f2f90d

https://git.kernel.org/stable/c/fc3ac2fcd0a7fad63eba1b359490a4b81720d0f9

https://git.kernel.org/stable/c/be9e2752d823eca1d5af67014a1844a9176ff566

https://git.kernel.org/stable/c/1040ef5ed95d6fd2628bad387d78a61633e09429

https://lists.debian.org/debian-lts-announce/2024/06/msg00017.html

https://lists.debian.org/debian-lts-announce/2024/06/msg00020.html

https://git.kernel.org/stable/c/1040ef5ed95d6fd2628bad387d78a61633e09429

Patch

https://git.kernel.org/stable/c/83fe1bbd9e259ad109827ccfbfc2488e0dea8e94

Patch

https://git.kernel.org/stable/c/851cc19bdb02556fb13629b3e4fef6f2bdb038fe

Patch

https://git.kernel.org/stable/c/9de184d4e557d550fb0b7b833b676bda4f269e4f

Patch

https://git.kernel.org/stable/c/b6b31b4c67ea6bd9222e5b73b330554c57f2f90d

Patch

https://git.kernel.org/stable/c/be9e2752d823eca1d5af67014a1844a9176ff566

Patch

https://git.kernel.org/stable/c/dd92b159c506804ac57adf3742d9728298bb1255

Patch

https://git.kernel.org/stable/c/e117c6e2d1617520f5f7d7f6f6b395f01d8b5a27

Patch

https://git.kernel.org/stable/c/fc3ac2fcd0a7fad63eba1b359490a4b81720d0f9

Patch

https://lists.debian.org/debian-lts-announce/2024/06/msg00017.html

Mailing List, Third Party Advisory

https://lists.debian.org/debian-lts-announce/2024/06/msg00020.html

Mailing List, Third Party Advisory

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.