This weakness occurs when a function, method, or code block contains too many levels of nested loops, conditionals, or other control structures, making the logic path difficult to follow.
Excessively deep nesting directly harms code maintainability. When developers struggle to understand the flow of deeply buried logic, they are more likely to introduce bugs during modifications, including security flaws like incorrect access controls or flawed input validation. This complexity acts as a breeding ground for vulnerabilities because critical security checks can be hidden within layers of conditional statements. From a security perspective, the primary risk is indirect. The time and effort required to audit, test, and fix such convoluted code increases significantly, delaying the discovery and remediation of existing security issues. To mitigate this, refactor deep nesting by extracting inner blocks into separate, well-named functions and employing guard clauses or early returns to flatten the overall structure, improving both security and code health.
Impact: Reduce Maintainability