Authorization / Out-Of-Bounds Read
Description
Out-of-bounds Read, also known as Out-of-bounds Read Access, is a type of authorization vulnerability that occurs when an application reads data outside the bounds of a buffer. This is a common vulnerability, and is cataloged in the CWE directory as CWE-126. According to OWASP, it is one of the most critical vulnerabilities, because it can lead to a wide range of outcomes such as information disclosure, corruption of data, and even remote code execution. It is a common vulnerability that exists in web and API applications. Out-of-bounds Read is included in the CWE Top 25 (2022).
Risk
Out-of-bounds Read is a very serious vulnerability with a high risk assessment. It can lead to information disclosure, data corruption, and even remote code execution. This can be extremely damaging to an organization, because it can lead to theft of confidential data or the disruption of critical services.
Solution
The solution to this vulnerability is to ensure that all data is properly validated before it is read or written. This can be done by using secure coding practices such as input validation, boundary checks, and proper error handling. In addition, it is important to make sure that all code is properly tested for this vulnerability.
Example
The following code example shows an example of an Out-of-bounds Read vulnerability in C. The code contains a buffer overflow vulnerability, which can lead to an Out-of-bounds Read.
#include <stdio.h>
int main() {
char buffer[10];
int i;
//Read user input
scanf("%s", buffer);
//Loop over the buffer
for (i = 0; i <= 11; i++) {
printf("%c", buffer[i]);
}
return 0;
}
The code example above contains a buffer overflow vulnerability, which can lead to an Out-of-bounds Read. This is because the loop iterates up to 11, even though the size of the buffer is only 10. As a result, the application will attempt to read data outside of the buffer, which can lead to an Out-of-bounds Read vulnerability.