CAPEC-53: Postfix, Null Terminate, and Backslash
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.
- Likelihood of attack
- High
- Typical severity
- High
- Abstraction
- DetailedA low-level, detailed pattern, often for a particular technology.
Mechanism of attack: Manipulate Data Structures
Prerequisites
- Null terminators are not properly handled by the filter.
Skills required
- MediumAn 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
- ConfidentialityAccess ControlAuthorization
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 weaknesses (CWE)
- CWE-20Improper Input Validation
- CWE-74Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')
- CWE-158Improper Neutralization of Null Byte or NUL Character
- CWE-172Encoding Error
- CWE-173Improper Handling of Alternate Encoding
- CWE-697Incorrect Comparison
- CWE-707Improper Neutralization