Common Attack Pattern Enumeration and Classification
A Community Resource for Identifying and Understanding Attacks
If a string is passed through a filter of some kind, then a terminal NULL may not be valid. Using alternate representation of NULL allows an attacker to embed the NULL mid-string while postfixing the proper data so that the filter is avoided. One example is a filter that looks for a trailing slash character. If a string insertion is possible, but the slash must exist, an alternate encoding of NULL in mid-string may be used.
Attack Execution Flow
A rather simple injection is possible in a URL:
helpwin.gas.bat?mode=&draw=x&file=x&module=&locale=[insert relative path here]
This attack has appeared with regularity in the wild. There are many variations of this kind of attack. Spending a short amount of time injecting against Web applications will usually result in a new exploit being discovered.
Skill or Knowledge Level: Medium
An attacker needs to understand alternate encodings, what the filter looks for and the data format acceptable to the target API
Test the program with various inputs and observe the behavior of the filter. Overtime it should be possible to understand what the filter is expecting.
Null characters are observed by the filter. The filter needs to be able to understand various encodings of the Null character, or only canonical data should be passed to it.
Properly handle Null characters. Make sure canonicalization is properly applied. Do not pass Null characters to the underlying APIs.
Assume all input is malicious. Create a white list that defines all valid input to the software system based on the requirements specifications. Input that does not match against the white list should not be permitted to enter into the system.
[R.53.1] [REF-2] G. Hoglund and G. McGraw. "Exploiting Software: How to Break Code". Addison-Wesley. February 2004.