Insecure Default Variable Initialization

Draft Variant
Structure: Simple
Description

The product, by default, initializes an internal variable with an insecure or less secure value than is possible.

Common Consequences 1
Scope: Integrity

Impact: Modify Application Data

An attacker could gain access to and modify sensitive data or system information.

Potential Mitigations 1
Phase: System Configuration
Disable or change default settings when they can be used to abuse the system. Since those default settings are shipped with the product they are likely to be known by a potential attacker who is familiar with the product. For instance, default credentials should be changed or the associated accounts should be disabled.
Demonstrative Examples 1

ID : DX-163

This code attempts to login a user using credentials from a POST request:

Code Example:

Bad
PHP

// $user and $pass automatically set from POST request* if (login_user($user,$pass)) { ``` $authorized = true; }

php
Because the $authorized variable is never initialized, PHP will automatically set $authorized to any value included in the POST request if register_globals is enabled. An attacker can send a POST request with an unexpected third value 'authorized' set to 'true' and gain authorized status without supplying valid credentials.
Here is a fixed version:

Code Example:

Good
PHP
php

...*

This code avoids the issue by initializing the $authorized variable to false and explicitly retrieving the login credentials from the $_POST variable. Regardless, register_globals should never be enabled and is disabled by default in current versions of PHP.
Observed Examples 1
CVE-2022-36349insecure default variable initialization in BIOS firmware for a hardware board allows DoS
Applicable Platforms
Languages:
PHP : SometimesNot Language-Specific : Undetermined
Modes of Introduction
Implementation
Taxonomy Mapping
  • PLOVER
Notes
MaintenanceThis overlaps other categories, probably should be split into separate items.