CAPEC-52 Embedding NULL Bytes

CAPEC ID: 52

CAPEC-52 Metadata

Likelihood of Attack

High

Typical Severity

High

Overview

Summary

An adversary embeds one or more null bytes in input to the target software. This attack relies on the usage of a null-valued byte as a string terminator in many environments. The goal is for certain components of the target software to stop processing the input when it encounters the null byte(s).

Prerequisites

The program does not properly handle postfix NULL terminators

Execution Flow

Step Phase Description Techniques
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.
  • Use a spidering tool to follow and record all links and analyze the web pages to find entry points. Make special note of any links that include parameters in the URL.
  • Use a proxy tool to record all user input entry points visited during a manual traversal of the web application.
  • Use a browser to manually explore the website and analyze how it is constructed. Many browsers' plugins are available to facilitate the analysis or automate the discovery.
  • Manually inspect the application to find entry points.
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) 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.
  • Try different encodings for null such as \0 or %00
3 Exploit [Remove data after null byte(s)] After determined entry points that are vulnerable, the adversary places a null byte(s) such that they remove data after the null byte(s) in a way that is beneficial to them.
  • If the input is a directory as part of a longer file path, add a null byte(s) at the end of the input to try to traverse to the given directory.

Potential Solutions / Mitigations

Properly handle the NULL characters supplied as part of user input prior to doing anything with the data.

Related Weaknesses (CWE)

CWE ID Description
CWE-20 Improper Input Validation
CWE-74 Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
CWE-158 Improper Neutralization of Null Byte or NUL Character
CWE-172 Encoding Error
CWE-173 Improper Handling of Alternate Encoding
CWE-697 Incorrect Comparison
CWE-707 Improper Neutralization

Related CAPECs

CAPEC ID Description
CAPEC-267 An adversary leverages the possibility to encode potentially harmful input or content used by applications such that the applications are ineffective at validating this encoding standard.

Taxonomy Mappings

Taxonomy: WASC

Entry ID Entry Name
28 Null Byte Injection

Taxonomy: OWASP Attacks

Entry ID Entry Name
Link Embedding Null Code

Stay Ahead of Attack Patterns

Understanding CAPEC patterns helps security professionals anticipate and thwart potential attacks. Leverage these insights to enhance threat modeling, strengthen your software development lifecycle, and train your security teams effectively.