Check out the new USENIX Web site. next up previous
Next: Exploitation techniques Up: Related work Previous: Runtime array bounds checking

Static analysis of array bounds checking

The integer range analysis by Wagner et al. [20] is a technique that detects possible buffer overflow in the vulnerable C library functions. A string buffer is modeled as a pair of integer ranges (lower bound, upper bound) for its allocated size and its current length. A set of integer constraints is predefined for a set of string operations (e.g. character array declaration, vulnerable C library functions and assignment statements involving them). Using those integer constraint, the technique analyzes the source code by checking each string buffer to see whether its inferred allocated size is at least as large as its inferred maximum length.

The annotation-assisted static analysis technique by Larochelle and Evans [12] based on LCLint [8] uses semantic comments, called annotations, provided by programmers to detect possible buffer overflow. For example, annotations for strcpy() contain an assertion that the destination buffer has been allocated to hold at least as many characters as are readable in the source buffer. This technique protects any annotated functions whereas the integer range analysis only protects C library functions.

Generally, a pure compile-time analysis like the above can produce many false alarms due to the lack of run time information. For example, gets() reads its input string from stdin so the size of the string is not known at compile time. For such a case a warning is issued as a possible buffer overflow. In fact, all the legitimate copy operations that accept their strings from unknown sources (such as a command line argument or an I/O channel) are flagged as possible buffer overflows (since they are indeed vulnerable). Without further action, those vulnerabilities are identified but still open to attack.


next up previous
Next: Exploitation techniques Up: Related work Previous: Runtime array bounds checking