Base · Medium

CWE-454: External Initialization of Trusted Variables or Data Stores

The product initializes critical internal variables or data stores using inputs that can be modified by untrusted actors.

CWE-454 · Base Level ·5 CVEs ·2 Mitigations

Description

The product initializes critical internal variables or data stores using inputs that can be modified by untrusted actors.

A product system should be reluctant to trust variables that have been initialized outside of its trust boundary, especially if they are initialized by users. The variables may have been initialized incorrectly. If an attacker can initialize the variable, then they can influence what the vulnerable system will do.

Potential Impact

Integrity

Modify Application Data

Demonstrative Examples

In the Java example below, a system property controls the debug level of the application.
Bad
int debugLevel = Integer.getInteger("com.domain.application.debugLevel").intValue();
If an attacker is able to modify the system property, then it may be possible to coax the application into divulging sensitive information by virtue of the fact that additional debug information is printed/exposed as the debug level increases.
This code checks the HTTP POST request for a debug switch, and enables a debug mode if the switch is set.
Bad
$debugEnabled = false;if ($_POST["debug"] == "true"){$debugEnabled = true;}
                     /.../
                     
                     function login($username, $password){if($debugEnabled){echo 'Debug Activated';phpinfo();$isAdmin = True;return True;}}
Any user can activate the debug mode, gaining administrator privileges. An attacker may also use the information printed by the phpinfo() function to further exploit the system. .
This example also exhibits Information Exposure Through Debug Information (CWE-215)

Mitigations & Prevention

Implementation

A product system should be reluctant to trust variables that have been initialized outside of its trust boundary. Ensure adequate checking (e.g. input validation) is performed when relying on input from outside a trust boundary.

Architecture and Design

Avoid any external control of variables. If necessary, restrict the variables that can be modified using an allowlist, and use a different namespace or naming convention if possible.

Detection Methods

  • Automated Static Analysis — Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then sea

Real-World CVE Examples

CVE IDDescription
CVE-2022-43468WordPress module sets internal variables based on external inputs, allowing false reporting of the number of views
CVE-2000-0959Does not clear dangerous environment variables, enabling symlink attack.
CVE-2001-0033Specify alternate configuration directory in environment variable, enabling untrusted path.
CVE-2001-0872Dangerous environment variable not cleansed.
CVE-2001-0084Specify arbitrary modules using environment variable.

Taxonomy Mappings

  • PLOVER: — External initialization of trusted variables or values
  • Software Fault Patterns: SFP25 — Tainted input to variable

Frequently Asked Questions

What is CWE-454?

CWE-454 (External Initialization of Trusted Variables or Data Stores) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The product initializes critical internal variables or data stores using inputs that can be modified by untrusted actors.

How can CWE-454 be exploited?

Attackers can exploit CWE-454 (External Initialization of Trusted Variables or Data Stores) to modify application data. This weakness is typically introduced during the Architecture and Design, Implementation phase of software development.

How do I prevent CWE-454?

Key mitigations include: A product system should be reluctant to trust variables that have been initialized outside of its trust boundary. Ensure adequate checking (e.g. input validation) is performed when relying on input fr

What is the severity of CWE-454?

CWE-454 is classified as a Base-level weakness (Medium abstraction). It has been observed in 5 real-world CVEs.