CWEweakness
CWE-561 Dead Code
- Abstraction
- Base
- Structure
- Simple
- Status
- Draft
- Languages
- Not Language-Specific
- CWE version
- 5.0
Description
The product contains dead code, which can never be executed.
Common consequences
• Other: Quality Degradation — Dead code that results from code that can never be executed is an indication of problems with the source code that needs to be fixed and is an indication of poor quality.
• Other: Reduce Maintainability
• Other: Varies by Context, Execute Unauthorized Code or Commands — In some cases, dead code can be reachable or exploitable by attackers after they exploit another weakness or vulnerability that can access the code. For example, some buffer overflow exploits could modify addresses to point to locations that contain dead code.
Potential mitigations
• [Implementation] Remove dead code before deploying the application.
Detection methods
• Architecture or Design Review: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
• Formal Methods / Correct-By-Construction
Cost effective for partial coverage:
• Attack Modeling
• Automated Static Analysis - Binary or Bytecode: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Binary / Bytecode Quality Analysis
• Compare binary / bytecode to application permission manifest
• Dynamic Analysis with Manual Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Automated Monitored Execution
• Automated Static Analysis: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Permission Manifest Analysis
• Automated Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Source Code Quality Analyzer
Cost effective for partial coverage:
• Warning Flags
• Source code Weakness Analyzer
• Context-configured Source Code Weakness Analyzer
• Dynamic Analysis with Automated Results Interpretation: According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
• Web Application Scanner
• Web Services Scanner
• Database Scanners
• Manual Static Analysis - Source Code: According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
• Manual Source Code Review (not inspections)
Cost effective for partial coverage:
• Focused Manual Spotcheck - Focused manual analysis of source
Observed examples
• 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-561 (Dead Code) -> CWE-295 (Improper Certificate Validation) -> CWE-393 (Return of Wrong Status Code) -> CWE-300 (Channel Accessible by Non-Endpoint). The code's whitespace indentation did not reflect the actual control flow (CWE-1114) and did not explicitly delimit the block (CWE-483), which could have made it more difficult for human code auditors to detect the vulnerability.
Related
Observed example · CVE (1)
- CVE-2014-1266 The SSLVerifySignedServerKeyExchange function in libsecurity_ssl/lib/sslKeyExchange.c in the Secure Transport feature in the Data Security… vulnerability
Child of · CWE (1)
- CWE-1164 Irrelevant Code weakness
Referenced by CVE · weakness (9)
- CVE-2026-44057 A dead bounds check in the Spotlight RPC unmarshaller in Netatalk 3.0.0 through 4.4.2 results in an unreachable code path that provides no… vulnerability
- CVE-2025-34205 Vasion Print (formerly PrinterLogic) Virtual Appliance Host versions prior to 22.0.843 and Application prior to 20.0.1923 (VA and SaaS… vulnerability
- CVE-2024-8300 Dead Code vulnerability in Mitsubishi Electric GENESIS64 Version 10.97.2, 10.97.2 CFR1, 10.97.2 CRF2 and 10.97.3, Mitsubishi Electric… vulnerability
- CVE-2024-32634 In huge memory get unmapped area check, code can never be reached because of a logical contradiction. vulnerability
- CVE-2022-33726 Unprotected dynamic receiver in Samsung Galaxy Friends prior to SMR Aug-2022 Release 1 allows attacker to launch activity. vulnerability
- CVE-2022-33685 Unprotected dynamic receiver in Wearable Manager Service prior to SMR Jul-2022 Release 1 allows attacker to launch arbitray activity and… vulnerability
- CVE-2022-30748 Unprotected dynamic receiver in Samsung Members prior to version 4.2.005 allows attacker to launch arbitrary activity. vulnerability
- CVE-2021-25398 Intent redirection vulnerability in Bixby Voice prior to version 3.1.12 allows attacker to access contacts. vulnerability
- CVE-2018-0039 Juniper Networks Contrail Service Orchestration releases prior to 4.0.0 have Grafana service enabled by default with hardcoded credentials. vulnerability
Referenced by CWE · can precede (2)
Referenced by CWE · child of (1)
- CWE-107 Struts: Unused Validation Form weakness
Referenced by CWE · has member (1)
- CWE-884 CWE Cross-section view