Description
The product contains code that is not essential for execution, i.e. makes no state changes and has no side effects that alter data or control flow, such that removal of the code would have no impact to functionality or correctness.
Irrelevant code could include dead code, initialization that is not used, empty blocks, code that could be entirely removed due to optimization, etc.
Potential Impact
Other
Reduce Reliability
Other
Reduce Performance
Demonstrative Examples
String s = null;if (b) {s = "Yes";return;}
if (s != null) {Dead();}r = getName();r = getNewBuffer(buf);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 sea
Real-World CVE Examples
| CVE ID | Description |
|---|---|
| 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-56 |
Related Weaknesses
Frequently Asked Questions
What is CWE-1164?
CWE-1164 (Irrelevant Code) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Class-level weakness. The product contains code that is not essential for execution, i.e. makes no state changes and has no side effects that alter data or control flow, such that removal of the code would have...
How can CWE-1164 be exploited?
Attackers can exploit CWE-1164 (Irrelevant Code) to reduce reliability. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-1164?
Follow secure coding practices, conduct code reviews, and use automated security testing tools (SAST/DAST) to detect this weakness early in the development lifecycle.
What is the severity of CWE-1164?
CWE-1164 is classified as a Class-level weakness (High abstraction). It has been observed in 1 real-world CVEs.