Description
The product contains an expression that will always evaluate to true.
Potential Impact
Other
Quality Degradation, Varies by Context
Demonstrative Examples
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 */
...
}
}Mitigations & Prevention
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 High — 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 sea
Related Weaknesses
Taxonomy Mappings
- CERT C Secure Coding: MSC00-C — Compile cleanly at high warning levels
- Software Fault Patterns: SFP1 — Glitch in computation
Frequently Asked Questions
What is CWE-571?
CWE-571 (Expression is Always True) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product contains an expression that will always evaluate to true.
How can CWE-571 be exploited?
Attackers can exploit CWE-571 (Expression is Always True) to quality degradation, varies by context. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-571?
Key mitigations include: Consider refactoring the code, or determine if the code is not including a condition that could cause the expression to become false.
What is the severity of CWE-571?
CWE-571 is classified as a Base-level weakness (Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.