---
title: "CWE-696: Incorrect Behavior Order"
url: https://radicalnotion.ai/cwe/cwe-696
type: cwe
description: "The product performs multiple related behaviors, but the behaviors are performed in the wrong order in ways that may produce resultant weaknesses."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-696: Incorrect Behavior Order

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

## Description

The product performs multiple related behaviors, but the behaviors are performed in the wrong order in ways that may produce resultant weaknesses.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | - |

## Applicable platforms

**Technologies:** Web Based (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Alter Execution Logic | - |

## 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 function prints the contents of a specified file requested by a user.

Bad code:

```php
function printFile($username,$filename){

    //read file into string
    $file = file_get_contents($filename);
    if ($file && isOwnerOf($username,$filename)){
        echo $file;
        return true;
    }
    else{
        echo 'You are not authorized to view this file';
    }
    return false;
}
```

This code first reads a specified file into memory, then prints the file if the user is authorized to see its contents. The read of the file into memory may be resource intensive and is unnecessary if the user is not allowed to see the file anyway.

### Example 3

Assume that the module foo\_bar implements a protected register. The register content is the asset. Only transactions made by user id (indicated by signal usr\_id) 0x4 are allowed to modify the register contents. The signal grant\_access is used to provide access.

Bad code:

```verilog
module foo_bar(data_out, usr_id, data_in, clk, rst_n);
output reg [7:0] data_out;
input wire [2:0] usr_id;
input wire [7:0] data_in;
input wire clk, rst_n;
wire grant_access;
always @ (posedge clk or negedge rst_n)
begin
    if (!rst_n)
        data_out = 0;
    else
        data_out = (grant_access) ? data_in : data_out;
        assign grant_access = (usr_id == 3'h4) ? 1'b1 : 1'b0;
end
endmodule
```

Good code:

```verilog
always @ (posedge clk or negedge rst_n)
begin
    if (!rst_n)
        data_out = 0;
    else
        assign grant_access = (usr_id == 3'h4) ? 1'b1 : 1'b0;
        data_out = (grant_access) ? data_in : data_out;
end
endmodule
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2019-9805 | Chain: Creation of the packet client occurs before initialization is complete (CWE-696) resulting in a read from uninitialized memory (CWE-908), causing memory corruption. |
| CVE-2007-5191 | file-system management programs call the setuid and setgid functions in the wrong order and do not check the return values, allowing attackers to gain unintended privileges |
| CVE-2007-1588 | C++ web server program calls Process::setuid before calling Process::setgid, preventing it from dropping privileges, potentially allowing CGI programs to be called with higher privileges than intended |
| CVE-2022-37734 | Chain: lexer in Java-based GraphQL server does not enforce maximum of tokens early enough (CWE-696), allowing excessive CPU consumption (CWE-1176) |

## Real CVEs with this weakness (sample of 12 of 61)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-132891 | - | critical | 9.8 | - | No | 2026-11-19 |
| CVE-2026-44108 | Firewall bypass during shutdown | critical | 9.3 | - | No | 2026-07-30 |
| CVE-2026-112186 | - | high | 8.7 | - | No | 2026-11-10 |
| CVE-2026-35627 | OpenClaw \< 2026.3.22 - Unauthenticated Cryptographic Work in Nostr Inbound DM Handling | high | 8.6 | - | No | 2026-04-09 |
| CVE-2026-45033 | GitHub Copilot CLI: Nested Bare Repository Can Execute Arbitrary Commands via core.fsmonitor | high | 8.5 | - | No | 2026-05-13 |
| CVE-2026-121291 | Security Advisory 0222 | high | 8.3 | - | No | 2026-11-10 |
| CVE-2026-123584 | Hickory-DNS 0.26.0 before 0.26.2 UDP Client Denial of Service via Spoofed Responses | high | 8.2 | - | No | 2026-11-08 |
| CVE-2026-14169 | ads-tec Industrial IT: Account lockout via non-atomic user creation | high | 8.1 | - | No | 2026-07-28 |
| CVE-2026-35386 | OpenSSH: OpenSSH: Arbitrary command execution via shell metacharacters in username | high | 8.1 | - | No | 2026-04-02 |
| CVE-2026-110450 | - | high | 8.0 | - | No | 2026-10-14 |
| CVE-2026-105745 | Docling: Plugin entry points are imported before the allow\_external\_plugins check | high | 7.8 | - | No | 2026-10-05 |
| CVE-2026-114145 | GitPython validates a submodule's ".git" path only after cloning into it (RCE) | high | 7.5 | - | No | 2026-10-21 |

## Related attack patterns (CAPEC)

- [CAPEC-463](https://radicalnotion.ai/capec/capec-463): Padding Oracle Crypto Attack

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-691](https://radicalnotion.ai/cwe/cwe-691) | Insufficient Control Flow Management |
| Child | [CWE-179](https://radicalnotion.ai/cwe/cwe-179) | Incorrect Behavior Order: Early Validation |
| Child | [CWE-408](https://radicalnotion.ai/cwe/cwe-408) | Incorrect Behavior Order: Early Amplification |
| Child | [CWE-551](https://radicalnotion.ai/cwe/cwe-551) | Incorrect Behavior Order: Authorization Before Parsing and Canonicalization |
| Child | [CWE-1190](https://radicalnotion.ai/cwe/cwe-1190) | DMA Device Enabled Too Early in Boot Phase |
| Child | [CWE-1193](https://radicalnotion.ai/cwe/cwe-1193) | Power-On of Untrusted Execution Core Before Enabling Fabric Access Control |
| Child | [CWE-1279](https://radicalnotion.ai/cwe/cwe-1279) | Cryptographic Operations are Run Before Supporting Units are Ready |
| Child | [CWE-1280](https://radicalnotion.ai/cwe/cwe-1280) | Access Control Check Implemented After Asset is Accessed |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Observe correct revocation order while relinquishing privileges | POS36-C | CWE More Abstract |

## Frequently asked questions

### What is CWE-696?

The product performs multiple related behaviors, but the behaviors are performed in the wrong order in ways that may produce resultant weaknesses.

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

61 recorded CVEs are attributed to CWE-696, including CVE-2026-132891, CVE-2026-44108 and CVE-2026-112186.

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

Exploiting CWE-696 can lead to: Alter Execution Logic.

### Is CWE-696 actively exploited?

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

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

---

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