CWE-571: Expression is Always True
The product contains an expression that will always evaluate to true.
Last updated
Overview
CWE-571 (Expression is Always True) is a base-level software weakness catalogued by MITRE in the Common Weakness Enumeration (CWE). It describes a recurring type of mistake that can lead to exploitable security vulnerabilities.
Common consequences
What can happen when CWE-571 is exploited.
Quality Degradation, Varies by Context
Affects: Other
How it happens
When it is introduced
Typically introduced during these phases of the software lifecycle.
How to prevent it
Practical mitigations for CWE-571, grouped by where in the lifecycle they apply.
Consider refactoring the code, or determine if the code is not including a condition that could cause the expression to become false.
How to detect it
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
Code examples
Illustrative examples from MITRE showing how the weakness appears in code.
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.
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.
Terminology & mappings
Mapped taxonomies
- CERT C Secure Coding: Compile cleanly at high warning levels (MSC00-C)
- Software Fault Patterns: Glitch in computation (SFP1)
Frequently asked questions
Common questions about CWE-571.
- What is CWE-571?
- The product contains an expression that will always evaluate to true.
- 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.
References
- MITRE CWE definition (CWE-571) (opens in a new tab)
- CWE-571 vulnerabilities on NVD (opens in a new tab)
- Learn: What is a CWE?
Weakness data is sourced from the MITRE CWE catalog (v4.20). CVE associations are aggregated and kept current by RadicalNotion.AI.
Stay ahead of CWE-571
Get alerted the moment a new CWE-571 vulnerability affects your stack, with AI-written analysis, severity context, and remediation guidance.