Improper Control of Dynamically-Managed Code Resources

Incomplete Class
Structure: Simple
Description

This vulnerability occurs when an application fails to properly secure access to code resources that can be created or altered at runtime, such as variables, functions, or objects.

Extended Description

Many modern programming languages provide powerful features for dynamic code manipulation, allowing developers to generate or modify code, objects, and functions while the application is running. While these capabilities offer great flexibility and can speed up development, they introduce significant risk if an attacker can influence what gets created or changed. Without strict controls, an attacker could inject malicious logic, alter critical data structures, or bypass security checks by manipulating these dynamic resources. To prevent this, developers must implement strong validation, enforce strict access controls, and avoid using user input directly in dynamic code operations.

Common Consequences 2
Scope: Integrity

Impact: Execute Unauthorized Code or Commands

Scope: OtherIntegrity

Impact: Varies by ContextAlter Execution Logic

Detection Methods 1
FuzzingHigh
Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.
Potential Mitigations 2
Phase: Implementation

Strategy: Input Validation

For any externally-influenced input, check the input against an allowlist of acceptable values.
Phase: ImplementationArchitecture and Design

Strategy: Refactoring

Refactor the code so that it does not need to be dynamically managed.
Observed Examples 5
CVE-2022-2054Python compiler uses eval() to execute malicious strings as Python code.
CVE-2018-1000613Cryptography API uses unsafe reflection when deserializing a private key
CVE-2015-8103Deserialization issue in commonly-used Java library allows remote execution.
CVE-2006-7079Chain: extract used for register_globals compatibility layer, enables path traversal (Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'))
CVE-2012-2055Source version control product allows modification of trusted key using mass assignment.
Modes of Introduction
Architecture and Design
Implementation