Incomplete Filtering of Special Elements

Incomplete Base
Structure: Simple
Description

This vulnerability occurs when an application accepts data from a source but fails to properly clean or neutralize all special characters or commands before passing that data to another system component.

Extended Description

Think of this as a faulty security checkpoint. The application performs some filtering on incoming data—like removing certain quotes or semicolons—but the filter's rules are incomplete. Attackers can craft inputs using alternative encodings, unexpected character combinations, or overlooked special elements to bypass these partial defenses. This incomplete sanitization leaves a gap between what the filter catches and what the downstream component actually interprets as a command, leading to injection flaws. For developers, the core issue is relying on a denylist or a partial allowlist approach. Effective prevention requires a positive security model: validate and encode data based on the specific context where it will be used (like SQL, OS commands, or HTML). Always use parameterized queries, trusted APIs, and standardized encoding libraries instead of attempting to manually filter or escape characters, as this approach is notoriously error-prone and difficult to maintain.

Common Consequences 1
Scope: Integrity

Impact: Unexpected State

Demonstrative Examples 1

ID : DX-2

The following code takes untrusted input and uses a regular expression to filter "../" from the input. It then appends this result to the /home/user/ directory and attempts to read the file in the final resulting path.

Code Example:

Bad
Perl
perl
Since the regular expression does not have the /g global match modifier, it only removes the first instance of "../" it comes across. So an input value such as:

Code Example:

Attack
bash
will have the first "../" stripped, resulting in:

Code Example:

Result
bash
This value is then concatenated with the /home/user/ directory:

Code Example:

Result
bash
which causes the /etc/passwd file to be retrieved once the operating system has resolved the ../ sequences in the pathname. This leads to relative path traversal (Relative Path Traversal).
Modes of Introduction
Implementation