Description
The code contains a control flow path that does not reflect the algorithm that the path is intended to implement, leading to incorrect behavior any time this path is navigated.
This weakness captures cases in which a particular code segment is always incorrect with respect to the algorithm that it is implementing. For example, if a C programmer intends to include multiple statements in a single block but does not include the enclosing braces (CWE-483), then the logic is always incorrect. This issue is in contrast to most weaknesses in which the code usually behaves correctly, except when it is externally manipulated in malicious ways.
Potential Impact
Other
Other, Alter Execution Logic
Demonstrative Examples
$requestingIP = $_SERVER['REMOTE_ADDR'];if(!in_array($requestingIP,$ipAllowList)){echo "You are not authorized to view this page";http_redirect($errorPageURL);}$status = getServerStatus();echo $status;
...if (condition==true)Do_X();Do_Y();public void printMessage(int month){
switch (month) {
case 1: print("January");case 2: print("February");case 3: print("March");case 4: print("April");case 5: print("May");case 6: print("June");case 7: print("July");case 8: print("August");case 9: print("September");case 10: print("October");case 11: print("November");case 12: print("December");
}println(" is a great month");
}void printMessage(int month){
switch (month) {
case 1: printf("January");case 2: printf("February");case 3: printf("March");case 4: printf("April");case 5: printff("May");case 6: printf("June");case 7: printf("July");case 8: printf("August");case 9: printf("September");case 10: printf("October");case 11: printf("November");case 12: printf("December");
}printf(" is a great month");
}String email = request.getParameter("email_address");assert email != null;Real-World CVE Examples
| CVE ID | Description |
|---|---|
| CVE-2021-3011 | virtual interrupt controller in a virtualization product allows crash of host by writing a certain invalid value to a register, which triggers a fatal error instead of returning an error code |
Related Weaknesses
Frequently Asked Questions
What is CWE-670?
CWE-670 (Always-Incorrect Control Flow Implementation) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Class-level weakness. The code contains a control flow path that does not reflect the algorithm that the path is intended to implement, leading to incorrect behavior any time this path is navigated.
How can CWE-670 be exploited?
Attackers can exploit CWE-670 (Always-Incorrect Control Flow Implementation) to other, alter execution logic. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-670?
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-670?
CWE-670 is classified as a Class-level weakness (High abstraction). It has been observed in 1 real-world CVEs.