CAPECattack pattern
CAPEC-52 Embedding NULL Bytes
High
Official page ↗
- Abstraction
- Detailed
- Status
- Draft
- Likelihood of attack
- High
- Typical severity
- High
- CAPEC version
- 3.9
Description
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).
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) 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) such that they remove data after the null byte(s) in a way that is beneficial to them.
Prerequisites
• The program does not properly handle postfix NULL terminators
Skills required
• [Medium] Directory traversal
• [High] Execution of arbitrary code
Consequences
• Integrity: Modify Data
• Confidentiality: Read Data
• Confidentiality, Access Control, Authorization: Gain Privileges
• Confidentiality, Integrity, Availability: Execute Unauthorized Commands
Mitigations
• Properly handle the NULL characters supplied as part of user input prior to doing anything with the data.
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