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.
View on MITREThe 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.
An attacker could gain unauthorized access to internal program variables and execute arbitrary code.
Refactor the code to avoid dynamic variable evaluation whenever possible.
Use only allowlists of acceptable variable or function names.
For function names, ensure that you are only calling functions that accept the proper number of arguments, to avoid unexpected null arguments.
No detection method information available for this CWE.
Chain: Dynamic variable evaluation allows resultant remote file inclusion and path traversal.
View DetailsChain: dynamic variable evaluation in PHP program used to modify critical, unexpected $_SERVER variable for resultant XSS.
View DetailsChain: dynamic variable evaluation in PHP program used to conduct remote file inclusion.
View DetailsDynamic variable evaluation in mail program allows reading and modifying attachments and preferences of other users.
View DetailsNo relationship information available for this CWE.
CWE-627: Dynamic Variable Evaluation is a Common Weakness Enumeration (CWE) entry maintained by MITRE. 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. 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.
If exploited, CWE-627 (Dynamic Variable Evaluation) it can compromise Confidentiality, Integrity and Availability, leading to outcomes such as Modify Application Data and Execute Unauthorized Code or Commands.
Recommended mitigations for CWE-627 include: Refactor the code to avoid dynamic variable evaluation whenever possible. Use only allowlists of acceptable variable or function names. For function names, ensure that you are only calling functions that accept the proper number of arguments, to avoid unexpected null arguments.
CWE-627 commonly affects PHP and Perl. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
MITRE documents real CVEs mapped to CWE-627, including CVE-2009-0422, CVE-2007-2431, CVE-2006-4904 and CVE-2006-4019. You can look up the full details of each CVE, including CVSS scores and remediation guidance, on our CVE Lookup tool.
A CWE (Common Weakness Enumeration) like CWE-627 describes a category of software weakness — the underlying flaw type. A CVE (Common Vulnerabilities and Exposures) identifies a specific, real-world vulnerability in a particular product. In short, a CWE is the kind of mistake, and a CVE is an instance of that mistake being found in software.