Null byte attacks
Null byte attacks exploit the fact that the C programming language (and related languages) use a null byte (0x00) to signify the end of a string. The string dog
, for example, is stored in memory in the following way when the C programming language is used:
|
|
|
|
In other programming languages, such as Java, strings are stored as arrays, and the total length of the string is stored in a separate location, which means that a Java string is perfectly capable of containing a null byte in the middle of the string.
This difference in how strings and null bytes are handled by different programming languages enable some attacks to take place that exploit the null byte to fool one part of a system by making it think a string has ended at a null byte, while another part will happily process the full input string.
Consider a simple JSP page that displays a text file to a visitor by using the filename parameter supplied to the page:
<% String filename = request...