---
title: "CWE-705: Incorrect Control Flow Scoping"
url: https://radicalnotion.ai/cwe/cwe-705
type: cwe
description: "The product does not properly return control flow to the proper location after it has completed a task or detected an unusual condition."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-705: Incorrect Control Flow Scoping

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

## Description

The product does not properly return control flow to the proper location after it has completed a task or detected an unusual condition.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Common consequences

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

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

## Demonstrative examples

### Example 1

The following example attempts to resolve a hostname.

Bad code:

```java
protected void doPost (HttpServletRequest req, HttpServletResponse res) throws IOException {
    String ip = req.getRemoteAddr();
    InetAddress addr = InetAddress.getByName(ip);
    ...
    out.println("hello " + addr.getHostName());
}
```

A DNS lookup failure will cause the Servlet to throw an exception.

### Example 2

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 3

Included in the doPost() method defined below is a call to System.exit() in the event of a specific exception.

Bad code:

```java
Public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
        ...
    } catch (ApplicationSpecificException ase) {
        logger.error("Caught: " + ase.toString());
        System.exit(1);
    }
}
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2023-21087 | Java code in a smartphone OS can encounter a "boot loop" due to an uncaught exception |
| CVE-2014-1266 | Chain: incorrect "goto" in Apple SSL product bypasses certificate validation, allowing Adversary-in-the-Middle (AITM) attack (Apple "goto fail" bug). CWE-705 (Incorrect Control Flow Scoping) -\> CWE-561 (Dead Code) -\> CWE-295 (Improper Certificate Validation) -\> CWE-393 (Return of Wrong Status Code) -\> CWE-300 (Channel Accessible by Non-Endpoint). The code's whitespace indentation did not reflect the actual control flow (CWE-1114) and did not explicitly delimit the block (CWE-483), which could have made it more difficult for human code auditors to detect the vulnerability. |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-53856 | TMM vulnerability | high | 8.7 | - | No | 2025-10-15 |
| CVE-2026-45819 | baseline-browser-mapping process termination on invalid input causes denial of service | medium | 6.6 | - | No | 2026-08-13 |
| CVE-2024-45433 | - | medium | 6.5 | - | No | 2025-09-12 |
| CVE-2026-3449 | @tootallnate/once vulnerable to Incorrect Control Flow Scoping | medium | 4.8 | - | No | 2026-03-03 |
| CVE-2026-40208 | Denial of service via DoH3 queries | low | 3.7 | - | No | 2026-06-25 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-691](https://radicalnotion.ai/cwe/cwe-691) | Insufficient Control Flow Management |
| Child | [CWE-248](https://radicalnotion.ai/cwe/cwe-248) | Uncaught Exception |
| Child | [CWE-382](https://radicalnotion.ai/cwe/cwe-382) | J2EE Bad Practices: Use of System.exit() |
| Child | [CWE-395](https://radicalnotion.ai/cwe/cwe-395) | Use of NullPointerException Catch to Detect NULL Pointer Dereference |
| Child | [CWE-396](https://radicalnotion.ai/cwe/cwe-396) | Declaration of Catch for Generic Exception |
| Child | [CWE-397](https://radicalnotion.ai/cwe/cwe-397) | Declaration of Throws for Generic Exception |
| Child | [CWE-455](https://radicalnotion.ai/cwe/cwe-455) | Non-exit on Failed Initialization |
| Child | [CWE-584](https://radicalnotion.ai/cwe/cwe-584) | Return Inside Finally Block |
| 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-768](https://radicalnotion.ai/cwe/cwe-768) | Incorrect Short Circuit Evaluation |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | All exit handlers must return normally | ENV32-C | CWE More Abstract |
| CERT C Secure Coding | Choose an appropriate termination strategy | ERR04-C | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not use Thread.stop() to terminate threads | THI05-J | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not complete abruptly from a finally block | ERR04-J | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not let checked exceptions escape from a finally block | ERR05-J | - |
| SEI CERT Perl Coding Standard | Do not suppress or ignore exceptions | EXP31-PL | Imprecise |

## Frequently asked questions

### What is CWE-705?

The product does not properly return control flow to the proper location after it has completed a task or detected an unusual condition.

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

5 recorded CVEs are attributed to CWE-705, including CVE-2025-53856, CVE-2026-45819 and CVE-2024-45433.

### How is CWE-705 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

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

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

### Is CWE-705 actively exploited?

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

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

---

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