Description
The product performs multiple related behaviors, but the behaviors are performed in the wrong order in ways that may produce resultant weaknesses.
Potential Impact
Integrity
Alter Execution Logic
Demonstrative Examples
String path = getInputPath();if (path.startsWith("/safe_dir/")){File f = new File(path);return f.getCanonicalPath();}String path = getInputPath();File f = new File(path);if (f.getCanonicalPath().startsWith("/safe_dir/")){return f.getCanonicalPath();}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;
}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
endmodulealways @ (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
endmoduleReal-World CVE Examples
| CVE ID | 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) |
Related Weaknesses
Taxonomy Mappings
- CERT C Secure Coding: POS36-C — Observe correct revocation order while relinquishing privileges
Frequently Asked Questions
What is CWE-696?
CWE-696 (Incorrect Behavior Order) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Class-level weakness. The product performs multiple related behaviors, but the behaviors are performed in the wrong order in ways that may produce resultant weaknesses.
How can CWE-696 be exploited?
Attackers can exploit CWE-696 (Incorrect Behavior Order) to alter execution logic. This weakness is typically introduced during the Architecture and Design, Implementation phase of software development.
How do I prevent CWE-696?
Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.
What is the severity of CWE-696?
CWE-696 is classified as a Class-level weakness (High abstraction). It has been observed in 4 real-world CVEs.