CAPECattack pattern

CAPEC-53 Postfix, Null Terminate, and Backslash

High Official page ↗
Abstraction
Detailed
Status
Draft
Likelihood of attack
High
Typical severity
High
CAPEC version
3.9

Description

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 adversary 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.

Execution flow

1. [Explore] [Survey the application for user-controllable inputs] Using a browser, an automated tool or by inspecting the application, an adversary records all entry points to the application. 2. [Experiment] [Probe entry points to locate vulnerabilities] The adversary uses the entry points gathered in the "Explore" phase as a target list and injects postfix null byte(s) followed by a backslash to observe how the application handles them as input. The adversary is looking for areas where user input is placed in the middle of a string, and the null byte causes the application to stop processing the string at the end of the user input. 3. [Exploit] [Remove data after null byte(s)] After determined entry points that are vulnerable, the adversary places a null byte(s) followed by a backslash such that they bypass an input filter and remove data after the null byte(s) in a way that is beneficial to them.

Prerequisites

• Null terminators are not properly handled by the filter.

Skills required

• [Medium] An adversary needs to understand alternate encodings, what the filter looks for and the data format acceptable to the target API

Consequences

• Integrity: Modify Data • Confidentiality: Read Data • Confidentiality, Access Control, Authorization: Gain Privileges

Mitigations

• 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 an allowlist that defines all valid input to the software system based on the requirements specifications. Input that does not match against the allowlist should not be permitted to enter into the system.

Related

Child of · CAPEC (1)

  • CAPEC-267 Leverage Alternate Encoding attack pattern

Weakness · CWE (7)

  • CWE-158 Improper Neutralization of Null Byte or NUL Character weakness
  • CWE-172 Improper Encoding or Decoding of Data weakness
  • CWE-173 Improper Handling of Alternate Encoding weakness
  • CWE-20 Improper Input Validation weakness
  • CWE-697 Incorrect Comparison weakness
  • CWE-707 Improper Neutralization weakness
  • CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness

Referenced by CWE · attack pattern (7)

  • CWE-158 Improper Neutralization of Null Byte or NUL Character weakness
  • CWE-172 Improper Encoding or Decoding of Data weakness
  • CWE-173 Improper Handling of Alternate Encoding weakness
  • CWE-20 Improper Input Validation weakness
  • CWE-697 Incorrect Comparison weakness
  • CWE-707 Improper Neutralization weakness
  • CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component weakness