Insufficient Encapsulation of Machine-Dependent Functionality

Incomplete Base
Structure: Simple
Description

This weakness occurs when an application relies on hardware-specific or platform-dependent features but fails to isolate that code from the rest of the system. This poor separation creates tight coupling between the core logic and low-level machine details.

Extended Description

When machine-dependent code—like direct hardware manipulation, processor-specific instructions, or OS-native calls—is scattered throughout an application, it creates a maintenance burden. Porting the software to a new architecture or platform becomes a complex, error-prone task of finding and updating every embedded dependency. This directly slows down development cycles and makes applying security patches more difficult. Indirectly, this complexity becomes a security liability. The increased effort to maintain or migrate the code makes it harder to identify and fix vulnerabilities in a timely manner. Developers are more likely to introduce flaws when modifying this entangled code, and the lack of clear boundaries can obscure security-critical logic. Properly encapsulating these dependencies behind clean interfaces is essential for long-term security and maintainability.

Common Consequences 1
Scope: Other

Impact: Reduce Maintainability

Demonstrative Examples 1

ID : DX-216

In this example function, the memory address of variable b is derived by adding 1 to the address of variable a. This derived address is then used to assign the value 0 to b.

Code Example:

Bad
C
c
Here, b may not be one byte past a. It may be one byte in front of a. Or, they may have three bytes between them because they are aligned on 32-bit boundaries.
References 1
Providing a Framework for Effective Software Quality Assessment
Robert A. Martin and Lawrence H. Shafer
07-1996
ID: REF-963