Initialization of a Resource with an Insecure Default

Incomplete Base
Structure: Simple
Description

The product initializes or sets a resource with a default that is intended to be changed by the administrator, but the default is not secure.

Extended Description

Developers often choose default values that leave the product as open and easy to use as possible out-of-the-box, under the assumption that the administrator can (or should) change the default value. However, this ease-of-use comes at a cost when the default is insecure and the administrator does not change it.

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 2
CVE-2022-36349insecure default variable initialization in BIOS firmware for a hardware board allows DoS
CVE-2022-42467A generic database browser interface has a default mode that exposes a web server to the network, allowing queries to the database.
Related Attack Patterns
Notes
MaintenanceThis entry improves organization of concepts under initialization. The typical CWE model is to cover "Missing" and "Incorrect" behaviors. Arguably, this entry could be named as "Incorrect" instead of "Insecure." This might be changed in the near future.