COMMON WEAKNESS ENUMERATIONIncomplete

CWE-627

Dynamic Variable Evaluation

In a language where the user can influence the name of a variable at runtime, if the variable names are not controlled, an attacker can read or write to arbitrary variables, or access arbitrary functions.

Soyutlama

Variant

Yapı

Simple

Sömürü İhtimali

Medium

Problemi anla

Problem nedir?

In a language where the user can influence the name of a variable at runtime, if the variable names are not controlled, an attacker can read or write to arbitrary variables, or access arbitrary functions.

Genişletilmiş açıklama

The resultant vulnerabilities depend on the behavior of the application, both at the crossover point and in any control/data flow that is reachable by the related variables or functions.

Terminoloji

Alternatif adlar ve kullanım biçimleri

Dynamic evaluation

Kök neden

Problem nasıl ve ne zaman oluşur?

Yaşam döngüsü evresi

Implementation

Many interpreted languages support the use of a "$$varname" construct to set a variable whose name is specified by the $varname variable. In PHP, these are referred to as "variable variables." Functions might also be invoked using similar syntax, such as $$funcname(arg1, arg2).

Risk

Başarılı sömürü neye yol açar?

Modify Application DataExecute Unauthorized Code or Commands

Etkilenen güvenlik alanları: Confidentiality, Integrity, Availability

An attacker could gain unauthorized access to internal program variables and execute arbitrary code.

Savunma

Nasıl önlenir ve çözülür?

Implementation

Refactoring

Detay
Refactor the code to avoid dynamic variable evaluation whenever possible.

Implementation

Input Validation

Detay
Use only allowlists of acceptable variable or function names.

Implementation

Uygulama aşaması savunması

Detay
For function names, ensure that you are only calling functions that accept the proper number of arguments, to avoid unexpected null arguments.