The product uses external input to determine the names of variables into which information is extracted, without verifying that the names of the specified variables are valid. This could cause the program to overwrite unintended variables.

For example, in PHP, extraction can be used to provide functionality similar to register_globals, a dangerous functionality that is frequently disabled in production systems. Calling extract() or import_request_variables() without the proper arguments could allow arbitrary global variables to be overwritten, including superglobals.
Similar functionality is possible in other interpreted languages, including custom languages.

Primary

Variable overwrite

Implementation

Integrity
Modify Application Data
An attacker could modify sensitive data or program variables.

Implementation
Input Validation
Use allowlists of variable names that can be extracted.

Implementation
Consider refactoring your code to avoid extraction routines altogether.

Implementation
In PHP, call extract() with options such as EXTR_SKIP and EXTR_PREFIX_ALL; call import_request_variables() with a prefix argument. Note that these capabilities are not present in all PHP versions.

This code uses the credentials sent in a POST request to login a user.

//Log user in, and set $isAdmin to true if user is an administrator

function login($user,$pass){$query = buildQuery($user,$pass);mysql_query($query);if(getUserRole($user) == "Admin"){$isAdmin = true;}}
$isAdmin = false;extract($_POST);login(mysql_real_escape_string($user),mysql_real_escape_string($pass));

The call to extract() will overwrite the existing values of any variables defined previously, in this case $isAdmin. An attacker can send a POST request with an unexpected third value "isAdmin" equal to "true", thus gaining Admin privileges.

CVE-2006-7135
extract issue enables file inclusion
https://www.cve.org/CVERecord?id=CVE-2006-7135

CVE-2006-7079
Chain: PHP app uses extract for register_globals compatibility layer (CWE-621), enabling path traversal (CWE-22)
https://www.cve.org/CVERecord?id=CVE-2006-7079

CVE-2007-0649
extract() buried in include files makes post-disclosure analysis confusing; original report had seemed incorrect.
https://www.cve.org/CVERecord?id=CVE-2007-0649

CVE-2006-6661
extract() enables static code injection
https://www.cve.org/CVERecord?id=CVE-2006-6661

CVE-2006-2828
import_request_variables() buried in include files makes post-disclosure analysis confusing
https://www.cve.org/CVERecord?id=CVE-2006-2828

SFP24
Tainted input to command

Allowed
This CWE entry is at the Variant level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.
Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.

Probably under-reported for PHP. Seems under-studied for other interpreted languages.

CWE Content Team
MITRE
2007-05-07
Draft 6
2007-05-07

Eric Dalci
Cigital
2008-07-01
updated Time_of_Introduction

CWE Content Team
MITRE
2008-09-08
updated Description, Relationships, Observed_Example, Other_Notes, Weakness_Ordinalities

CWE Content Team
MITRE
2008-10-14
updated Description

CWE Content Team
MITRE
2011-06-01
updated Common_Consequences

CWE Content Team
MITRE
2012-05-11
updated Common_Consequences, Demonstrative_Examples, Relationships

CWE Content Team
MITRE
2012-10-30
updated Potential_Mitigations

CWE Content Team
MITRE
2013-02-21
updated Demonstrative_Examples, Relationships

CWE Content Team
MITRE
2014-06-23
updated Description, Other_Notes

CWE Content Team
MITRE
2014-07-30
updated Relationships, Taxonomy_Mappings

CWE Content Team
MITRE
2020-02-24
updated Relationships

CWE Content Team
MITRE
2020-06-25
updated Potential_Mitigations

CWE Content Team
MITRE
2022-04-28
updated Research_Gaps

CWE Content Team
MITRE
2023-04-27
updated Relationships, Type

CWE Content Team
MITRE
2023-06-29
updated Mapping_Notes

CWE Content Team
MITRE
2023-10-26
updated Observed_Examples