---
title: "CWE-571: Expression is Always True"
url: https://radicalnotion.ai/cwe/cwe-571
type: cwe
description: "The product contains an expression that will always evaluate to true."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-571: Expression is Always True

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

## Description

The product contains an expression that will always evaluate to true.

## Modes of introduction

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

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Quality Degradation, Varies by Context | - |

## Potential mitigations

### Implementation (Refactoring)

Consider refactoring the code, or determine if the code is not including a condition that could cause the expression to become false.

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

Effectiveness: High

## Demonstrative examples

### Example 1

In the following Java example the updateInventory() method used within an e-business product ordering/inventory application will check if the input product number is in the store or in the warehouse. If the product is found, the method will update the store or warehouse database as well as the aggregate product database. If the product is not found, the method intends to do some special processing without updating any database.

Bad code:

```java
public void updateInventory(String productNumber) {
    boolean isProductAvailable = false;
    boolean isDelayed = false;

    if (productInStore(productNumber)) {
        isProductAvailable = true;
        updateInStoreDatabase(productNumber);
    }
    else if (productInWarehouse(productNumber)) {
        isProductAvailable = true;
        updateInWarehouseDatabase(productNumber);
    }
    else {
        isProductAvailable = true;
    }

    if ( isProductAvailable ) {
        updateProductDatabase(productNumber);
    }
    else if ( isDelayed ) {

        /* Warn customer about delay before order processing */
        ...
    }
}
```

However, the method never sets the isDelayed variable and instead will always update the isProductAvailable variable to true. The result is that the predicate testing the isProductAvailable boolean will always evaluate to true and therefore always update the product database. Further, since the isDelayed variable is initialized to false and never changed, the expression always evaluates to false and the customer will never be warned of a delay on their product.

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2022-31017 | Expression Always True vulnerability in Zulip Server | low | 2.6 | - | No | 2022-06-25 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-710](https://radicalnotion.ai/cwe/cwe-710) | Improper Adherence to Coding Standards |
| Can precede | [CWE-561](https://radicalnotion.ai/cwe/cwe-561) | Dead Code |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Compile cleanly at high warning levels | MSC00-C | - |
| Software Fault Patterns | Glitch in computation | SFP1 | - |

## Frequently asked questions

### What is CWE-571?

The product contains an expression that will always evaluate to true.

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

1 recorded CVE is attributed to CWE-571: CVE-2022-31017.

### How do you prevent CWE-571?

Consider refactoring the code, or determine if the code is not including a condition that could cause the expression to become false.

### How is CWE-571 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-571?

Exploiting CWE-571 can lead to: Quality Degradation, Varies by Context.

### Is CWE-571 actively exploited?

1 recorded CVE is caused by CWE-571; it is not currently in CISA's KEV catalog of actively exploited flaws.

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

---

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