---
title: "CWE-796: Only Filtering Special Elements Relative to a Marker"
url: https://radicalnotion.ai/cwe/cwe-796
type: cwe
description: "The product receives data from an upstream component, but only accounts for special elements positioned relative to a marker (e.g. \"at the beginning/end of a string; the second argument\"), thereby missing remaining special elements that may exist before sending it to a downstream component."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-796: Only Filtering Special Elements Relative to a Marker

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 0
- **Of those, in CISA KEV:** 0
- **New in 2026:** 0
- **CWE catalog version:** 4.21

## Description

The product receives data from an upstream component, but only accounts for special elements positioned relative to a marker (e.g. "at the beginning/end of a string; the second argument"), thereby missing remaining special elements that may exist before sending it to a downstream component.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | REALIZATION: This weakness is caused during implementation of an architectural security tactic. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Unexpected State | - |

## Demonstrative examples

### Example 1

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

Bad code:

```perl
my $Username = GetUntrustedInput();
$Username =~ s/^\.\.\///;
my $filename = "/home/user/" . $Username;
ReadAndSendFile($filename);
```

Attack code:

```
../../../etc/passwd
```

Result code:

```
../../etc/passwd
```

Result code:

```
/home/user/../../etc/passwd
```

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-795](https://radicalnotion.ai/cwe/cwe-795) | Only Filtering Special Elements at a Specified Location |

## Frequently asked questions

### What is CWE-796?

The product receives data from an upstream component, but only accounts for special elements positioned relative to a marker (e.g. "at the beginning/end of a string; the second argument"), thereby missing remaining special elements that may exist before sending it to a downstream component.

### What are the consequences of CWE-796?

Exploiting CWE-796 can lead to: Unexpected State.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/796.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-796). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
