Use of Invariant Value in Dynamically Changing Context

Draft Base
Structure: Simple
Description

This vulnerability occurs when code uses a fixed, unchanging value (like a hardcoded string, number, or reference) in a situation where that value should actually be flexible and adapt to different runtime conditions or environments.

Extended Description

Developers often hardcode values like file paths, configuration settings, API endpoints, or cryptographic keys for simplicity during initial development. The problem arises when the application is deployed across different stages (like development, testing, and production) or for different users, as these invariant values fail to adjust. This forces the same static value to be used everywhere, which typically breaks functionality, exposes sensitive data, or creates security misconfigurations. To prevent this, you should externalize all environment-specific values into configuration files, environment variables, or secure secret management services. This practice, central to DevOps and secure CI/CD pipelines, ensures your application can dynamically pull the correct database credentials, service URLs, or feature flags for each specific deployment context without requiring code changes.

Common Consequences 1
Scope: Other

Impact: Varies by Context

Demonstrative Examples 2

ID : DX-14

The following code is an example of an internal hard-coded password in the back-end:

Code Example:

Bad
C
c

Code Example:

Bad
Java
java
Every instance of this program can be placed into diagnostic mode with the same password. Even worse is the fact that if this program is distributed as a binary-only distribution, it is very difficult to change that password or disable this "functionality."

ID : DX-192

This code assumes a particular function will always be found at a particular address. It assigns a pointer to that address and calls the function.

Code Example:

Bad
C
c

// Here we can inject code to execute.*

The same function may not always be found at the same memory address. This could lead to a crash, or an attacker may alter the memory at the expected address, leading to arbitrary code execution.
Observed Examples 1
CVE-2002-0980Component for web browser writes an error message to a known location, which can then be referenced by attackers to process HTML/script in a less restrictive context
References 1
FIPS PUB 140-2: SECURITY REQUIREMENTS FOR CRYPTOGRAPHIC MODULES
Information Technology Laboratory, National Institute of Standards and Technology
25-05-2001
ID: REF-267
Applicable Platforms
Languages:
Not Language-Specific : Undetermined
Modes of Introduction
Architecture and Design
Implementation
Related Weaknesses
Taxonomy Mapping
  • PLOVER
Notes
Relationshipoverlaps default configuration.