---
title: "CWE-179: Incorrect Behavior Order: Early Validation"
url: https://radicalnotion.ai/cwe/cwe-179
type: cwe
description: "The product validates input before applying protection mechanisms that modify the input."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-179: Incorrect Behavior Order: Early Validation

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

## Description

The product validates input before applying protection mechanisms that modify the input.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | Since early validation errors usually arise from improperly implemented defensive mechanisms, it is likely that these will be introduced more frequently as secure programming becomes implemented more widely. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Access Control, Integrity | Bypass Protection Mechanism, Execute Unauthorized Code or Commands | An attacker could bypass the protection mechanism by including dangerous inputs that are only produced after the modification (such as canonicalization and cleansing). This can be used to launch various attacks including injection, executing arbitrary code, or causing other unintended behavior. |

## Potential mitigations

### Implementation (Input Validation)

Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

## Demonstrative examples

### Example 1

The following code attempts to validate a given input path by checking it against an allowlist and then return the canonical path. In this specific case, the path is considered valid if it starts with the string "/safe\_dir/".

Bad code:

```java
String path = getInputPath();
if (path.startsWith("/safe_dir/"))
{
    File f = new File(path);
    return f.getCanonicalPath();
}
```

Good code:

```java
String path = getInputPath();
File f = new File(path);
if (f.getCanonicalPath().startsWith("/safe_dir/"))
{
    return f.getCanonicalPath();
}
```

### Example 2

This script creates a subdirectory within a user directory and sets the user as the owner.

Bad code:

```php
function createDir($userName,$dirName){
    $userDir = '/users/'. $userName;
    if(strpos($dirName,'..') !== false){
        echo 'Directory name contains invalid sequence';
        return;
    }
    //filter out '~' because other scripts identify user directories by this prefix
    $dirName = str_replace('~','',$dirName);
    $newDir = $userDir . $dirName;
    mkdir($newDir, 0700);
    chown($newDir,$userName);
}
```

While the script attempts to screen for '..' sequences, an attacker can submit a directory path including ".~.", which will then become ".." after the filtering step. This allows a Path Traversal (CWE-21) attack to occur.

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2002-0433 | List files in web server using "\*.ext" |
| CVE-2003-0332 | Product modifies the first two letters of a filename extension after performing a security check, which allows remote attackers to bypass authentication via a filename with a .ats extension instead of a .hts extension. |
| CVE-2002-0802 | Database consumes an extra character when processing a character that cannot be converted, which could remove an escape character from the query and make the application subject to SQL injection attacks. |
| CVE-2000-0191 | Overlaps "fakechild/../realchild" |
| CVE-2004-2363 | Product checks URI for "\<" and other literal characters, but does it before hex decoding the URI, so "%3E" and other sequences are allowed. |
| CVE-2002-0934 | Directory traversal vulnerability allows remote attackers to read or modify arbitrary files via invalid characters between two . (dot) characters, which are filtered and result in a ".." sequence. |
| CVE-2003-0282 | Directory traversal vulnerability allows attackers to overwrite arbitrary files via invalid characters between two . (dot) characters, which are filtered and result in a ".." sequence. |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2022-1271 | gzip: arbitrary-file-write vulnerability | high | 8.8 | - | No | 2022-08-31 |
| CVE-2026-64389 | ksmbd: validate NTLMv2 response before updating session key | high | 8.2 | - | No | 2026-07-25 |
| CVE-2026-68445 | drm/vc4: Prevent shader BO mappings from becoming writable | high | 7.8 | - | No | 2026-08-12 |
| CVE-2026-49414 | ASLR bypass for setuid executables via procctl(2) | high | 7.8 | - | No | 2026-06-27 |
| CVE-2026-108169 | Code execution through web query files given on the command line | high | 7.3 | - | No | 2026-11-16 |
| CVE-2024-41686 | Password Policy Bypass Vulnerability | high | 7.3 | - | No | 2024-07-26 |
| CVE-2025-4759 | lockfile-lint-api Vulnerable to Incorrect Behavior Order | medium | 6.9 | - | No | 2025-05-16 |
| CVE-2026-84177 | Apache Wicket: A component's markup is served as a package resource when its class name contains an underscore | medium | 6.3 | - | No | 2026-11-01 |
| CVE-2022-49269 | can: isotp: sanitize CAN ID checks in isotp\_bind() | medium | 5.5 | - | No | 2025-02-26 |
| CVE-2026-99803 | io\_uring/net: mask socket type with SOCK\_TYPE\_MASK in io\_socket\_bpf\_populate() | medium | 4.4 | - | No | 2026-11-20 |
| CVE-2025-54508 | - | medium | 4.0 | - | No | 2026-11-10 |
| CVE-2026-3832 | Gnutls: gnutls: security bypass allows acceptance of revoked server certificates via crafted ocsp response | low | 3.7 | - | No | 2026-04-30 |

## Related attack patterns (CAPEC)

- [CAPEC-3](https://radicalnotion.ai/capec/capec-3): Using Leading 'Ghost' Character Sequences to Bypass Input Filters
- [CAPEC-43](https://radicalnotion.ai/capec/capec-43): Exploiting Multiple Input Interpretation Layers
- [CAPEC-71](https://radicalnotion.ai/capec/capec-71): Using Unicode Encoding to Bypass Validation Logic

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-20](https://radicalnotion.ai/cwe/cwe-20) | Improper Input Validation |
| Parent | [CWE-696](https://radicalnotion.ai/cwe/cwe-696) | Incorrect Behavior Order |
| Child | [CWE-180](https://radicalnotion.ai/cwe/cwe-180) | Incorrect Behavior Order: Validate Before Canonicalize |
| Child | [CWE-181](https://radicalnotion.ai/cwe/cwe-181) | Incorrect Behavior Order: Validate Before Filter |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| PLOVER | Early Validation Errors | - | - |

## Frequently asked questions

### What is CWE-179?

The product validates input before applying protection mechanisms that modify the input.

### What CVEs are caused by CWE-179?

12 recorded CVEs are attributed to CWE-179, including CVE-2022-1271, CVE-2026-64389 and CVE-2026-68445.

### How do you prevent CWE-179?

Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

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

Exploiting CWE-179 can lead to: Bypass Protection Mechanism, Execute Unauthorized Code or Commands.

### Is CWE-179 actively exploited?

12 recorded CVEs are caused by CWE-179; none are currently in CISA's KEV catalog of actively exploited flaws.

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

---

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