---
title: "CWE-670: Always-Incorrect Control Flow Implementation"
url: https://radicalnotion.ai/cwe/cwe-670
type: cwe
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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-670: Always-Incorrect Control Flow Implementation

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

## 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.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | This issue typically appears in rarely-tested code, since the "always-incorrect" nature will be detected as a bug during normal usage. |

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Other, Alter Execution Logic | - |

## Demonstrative examples

### Example 1

This code queries a server and displays its status when a request comes from an authorized IP address.

Bad code:

```php
$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;
...
```

This code redirects unauthorized users, but continues to execute code after calling http\_redirect(). This means even unauthorized users may be able to access the contents of the page or perform a DoS attack on the server being queried. Also, note that this code is vulnerable to an IP address spoofing attack (CWE-212).

### Example 2

In this example, the programmer has indented the statements to call Do\_X() and Do\_Y(), as if the intention is that these functions are only called when the condition is true. However, because there are no braces to signify the block, Do\_Y() will always be executed, even if the condition is false.

Bad code:

```c
if (condition==true)
    Do_X();
    Do_Y();
```

This might not be what the programmer intended. When the condition is critical for security, such as in making a security decision or detecting a critical error, this may produce a vulnerability.

### Example 3

In both of these examples, a message is printed based on the month passed into the function:

Bad code:

```java
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");
}
```

Bad code:

```c
void printMessage(int month){
    switch (month) {

        case 1: printf("January");
        case 2: printf("February");
        case 3: printf("March");
        case 4: printf("April");
        case 5: printf("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");
}
```

Both examples do not use a break statement after each case, which leads to unintended fall-through behavior. For example, calling "printMessage(10)" will result in the text "OctoberNovemberDecember is a great month" being printed.

### Example 4

In the excerpt below, an AssertionError (an unchecked exception) is thrown if the user hasn't entered an email address in an HTML form.

Bad code:

```java
String email = request.getParameter("email_address");
assert email != null;
```

## Observed examples

| CVE | 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 |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-79608 | x86/AMD: ineffectual Zenbleed workaround | critical | 9.8 | - | No | 2026-10-13 |
| CVE-2025-43359 | iOS and iPadOS: Kernel - A UDP server socket bound to a local interface may become bound to all interfaces | critical | 9.8 | - | No | 2025-09-15 |
| CVE-2023-23623 | Content-Secrity-Policy disabling eval not applied consistently in renderers with sandbox disabled in Electron | critical | 9.8 | - | No | 2023-09-06 |
| CVE-2022-25745 | Always Incorrect Control Flow Implementation in MODEM | critical | 9.8 | - | No | 2023-04-04 |
| CVE-2022-2993 | bt: host: Wrong key validation check | critical | 9.8 | - | No | 2022-12-12 |
| CVE-2022-21679 | Authorization Policy bypass in Istio | critical | 9.8 | - | No | 2022-01-19 |
| CVE-2021-41153 | Specification non-compliance in JUMPI | critical | 9.8 | - | No | 2021-10-18 |
| CVE-2020-1914 | Always-Incorrect Control Flow Implementation in Facebook Hermes | critical | 9.8 | - | No | 2020-10-08 |
| CVE-2020-17466 | - | critical | 9.8 | - | No | 2020-08-11 |
| CVE-2019-17192 | - | critical | 9.8 | - | No | 2019-10-05 |
| CVE-2025-24800 | Critical vulnerability in \`ismp-grandpa\` \<v15.0.1 | critical | 9.3 | - | No | 2025-01-28 |
| CVE-2026-55276 | Apache Tomcat: Logged effective web.xml is incomplete | critical | 9.1 | - | No | 2026-06-29 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-691](https://radicalnotion.ai/cwe/cwe-691) | Insufficient Control Flow Management |
| Child | [CWE-480](https://radicalnotion.ai/cwe/cwe-480) | Use of Incorrect Operator |
| Child | [CWE-483](https://radicalnotion.ai/cwe/cwe-483) | Incorrect Block Delimitation |
| Child | [CWE-484](https://radicalnotion.ai/cwe/cwe-484) | Omitted Break Statement in Switch |
| Child | [CWE-617](https://radicalnotion.ai/cwe/cwe-617) | Reachable Assertion |
| Child | [CWE-698](https://radicalnotion.ai/cwe/cwe-698) | Execution After Redirect (EAR) |
| Child | [CWE-783](https://radicalnotion.ai/cwe/cwe-783) | Operator Precedence Logic Error |

## Frequently asked questions

### What is CWE-670?

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.

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

156 recorded CVEs are attributed to CWE-670, including CVE-2026-79608, CVE-2025-43359 and CVE-2023-23623.

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

Exploiting CWE-670 can lead to: Other, Alter Execution Logic.

### Is CWE-670 actively exploited?

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

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

---

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