Description
The product contains dead code, which can never be executed.
Dead code is code that can never be executed in a running program. The surrounding code makes it impossible for a section of code to ever be executed.
Potential Impact
Other
Quality Degradation
Other
Reduce Maintainability
Demonstrative Examples
String s = null;if (b) {s = "Yes";return;}
if (s != null) {Dead();}public class DoubleDead {private void doTweedledee() {doTweedledumb();}private void doTweedledumb() {doTweedledee();}public static void main(String[] args) {System.out.println("running DoubleDead");}}public class Dead {
String glue;
public String getGlue() {return "glue";}
}Mitigations & Prevention
Remove dead code before deploying the application.
Detection Methods
- Architecture or Design Review High — According to SOAR [REF-1479], the following detection techniques may be useful:
- Automated Static Analysis - Binary or Bytecode High — According to SOAR [REF-1479], the following detection techniques may be useful:
- Dynamic Analysis with Manual Results Interpretation SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
- Automated Static Analysis SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
- Automated Static Analysis - Source Code High — According to SOAR [REF-1479], the following detection techniques may be useful:
- Dynamic Analysis with Automated Results Interpretation SOAR Partial — According to SOAR [REF-1479], the following detection techniques may be useful:
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
Taxonomy Mappings
- CERT C Secure Coding: MSC07-C — Detect and remove dead code
- SEI CERT Perl Coding Standard: MSC00-PL — Detect and remove dead code
- Software Fault Patterns: SFP2 — Unused Entities
- OMG ASCMM: ASCMM-MNT-20 —
Frequently Asked Questions
What is CWE-561?
CWE-561 (Dead Code) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product contains dead code, which can never be executed.
How can CWE-561 be exploited?
Attackers can exploit CWE-561 (Dead Code) to quality degradation. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-561?
Key mitigations include: Remove dead code before deploying the application.
What is the severity of CWE-561?
CWE-561 is classified as a Base-level weakness (Medium abstraction). It has been observed in 1 real-world CVEs.