Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CWE-570 (表达式永假) — Vulnerability Class 1

1 vulnerabilities classified as CWE-570 (表达式永假). AI Chinese analysis included.

CWE-570 represents a logical error weakness where a conditional expression is statically determined to always evaluate to false, rendering the associated code path unreachable. This flaw typically arises from incorrect operator usage, such as confusing equality with assignment, or from outdated logic that fails to account for updated variable states or data types. While not directly exploitable for remote code execution, it undermines software integrity by creating dead code that obscures the intended control flow, potentially hiding security vulnerabilities or causing unexpected behavior during maintenance. Developers avoid this weakness by employing static analysis tools to detect unreachable branches, utilizing compiler warnings for suspicious comparisons, and rigorously reviewing conditional logic during code reviews to ensure expressions accurately reflect the intended business rules and data constraints.

MITRE CWE Description
The product contains an expression that will always evaluate to false.
Common Consequences (1)
OtherQuality Degradation, Varies by Context
Mitigations (1)
ImplementationConsider refactoring the code, or determine if the code is not including a condition that could cause the expression to become false.
Examples (2)
In the following Java example the updateUserAccountOrder() method used within an e-business product ordering/inventory application will validate the product number that was ordered and the user account number. If they are valid, the method will update the product inventory, the user account, and the user order appropriately.
public void updateUserAccountOrder(String productNumber, String accountNumber) { boolean isValidProduct = false; boolean isValidAccount = false; if (validProductNumber(productNumber)) { isValidProduct = true; updateInventory(productNumber); } else { return; } if (validAccountNumber(accountNumber)) { isValidProduct = true; updateAccount(accountNumber, productNumber); } if (isValidProduct && isValidAccount) { updateAccountOrder(accountNumber, productNumber); } }
Bad · Java
... if (validAccountNumber(accountNumber)) { isValidAccount = true; updateAccount(accountNumber, productNumber); } ...
Good · Java
In the following example, the hasReadWriteAccess method uses bit masks and bit operators to determine if a user has read and write privileges for a particular process. The variable mask is defined as a bit mask from the BIT_READ and BIT_WRITE constants that have been defined. The variable mask is used within the predicate of the hasReadWriteAccess method to determine if the userMask input paramete…
#define BIT_READ 0x0001 // 00000001 #define BIT_WRITE 0x0010 // 00010000 unsigned int mask = BIT_READ & BIT_WRITE; /* intended to use "|" */ // using "&", mask = 00000000 // using "|", mask = 00010001 // determine if user has read and write access int hasReadWriteAccess(unsigned int userMask) { // if the userMask has read and write bits set // then return 1 (true) if (userMask & mask) { return 1; } // otherwise return 0 (false) return 0; }
Bad · C
CVE IDTitleCVSSSeverityPublished
CVE-2024-32633 Unsigned compared against 0 — Falcon/Crane 4.0 Medium2024-04-16

Vulnerabilities classified as CWE-570 (表达式永假) represent 1 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.