CAPEC-53 - Postfix, Null Terminate, and Backslash

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 Methods 1
  • Injection
  • Purposes 1
  • Penetration
  • Sec Principles 1
  • Reluctance to Trust
  • Scopes 3
  • Modify application data
  • Integrity
  • Read memory
  • Confidentiality
  • Gain privileges / assume identity
  • Authorization
  • Access_Control
  • Confidentiality

Medium level: An attacker needs to understand alternate encodings, what the filter looks for and the data format acceptable to the target API

Null terminators are not properly handled by the filter.

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.

Step 1 -

An attacker first probes to figure out what restrictions on input are placed by filter, such as a specific characters on the end of the URL..

Step 1 -

The attacker then injects a string of their choosing with a null terminator (using an alternate encoding such as %00), followed by a backslash (%5C), followed by some additional characters that are required to keep the filter happy.

Step 2 -

The malicious string then passes through the filter and passed to the underlying API. Everything after the null terminator is ignored. This may give an attacker the opportunity to access file system resources to which they should not have access and do other things..

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.