Weakness · Medium
CWE-561: Dead Code
What it is
The product contains dead code, which can never be executed.
- Severity (our rating)
- Medium
- Likelihood of exploit
- Not rated by MITRE
- Introduced during
- Implementation
- Exploited in the wild
- No CVE in CISA's catalog
In more detail
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.
What an attacker can do
- Quality Degradation (Other)
- Reduce Maintainability (Other)
How to prevent it
Implementation
- Remove dead code before deploying the application.
Testing
- Use a static analysis tool to spot dead code.
How to find it
- Architecture or Design Review. According to SOAR, 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, 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, the following detection techniques may be useful: Cost effective for partial coverage: Automated Monitored Execution
- Automated Static Analysis. According to SOAR, the following detection techniques may be useful: Cost effective for partial coverage: Permission Manifest Analysis
- Automated Static Analysis - Source Code. According to SOAR, 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, 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, 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
H2 Security
Found it in your code?
We review where it appears, fix it with your team, and check it was not already used against you.
Talk to our teamT Academy
Stop writing it in the first place
Learn to build software and systems without weaknesses like this one, with practice on real hosts in your browser, every objective checked on the machine.
Start freeSource: MITRE Common Weakness Enumeration, CWE version 4.19.1. CWE is a trademark of The MITRE Corporation.