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.
View on MITREExtended Description
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.
Technical Details
- Structure
- Simple
Applicable To
Security Consequences
Scope
Impact
An attacker could gain unauthorized access to internal program variables and execute arbitrary code.
Mitigation Strategies
Phase
Description
Refactor the code to avoid dynamic variable evaluation whenever possible.
Strategy
RefactoringPhase
Description
Use only allowlists of acceptable variable or function names.
Strategy
Input ValidationPhase
Description
For function names, ensure that you are only calling functions that accept the proper number of arguments, to avoid unexpected null arguments.
Detection Methods
No detection method information available for this CWE.
Code Examples & CVEs
Observed CVE Examples (4)
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 DetailsCWE Relationships
No relationship information available for this CWE.
Frequently Asked Questions
What is CWE-627: Dynamic Variable Evaluation?+
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.
What are the security consequences of Dynamic Variable Evaluation?+
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.
How do you prevent or mitigate Dynamic Variable Evaluation?+
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.
Which programming languages are affected by Dynamic Variable Evaluation?+
CWE-627 commonly affects PHP and Perl. Note that weaknesses are often language-agnostic patterns, so secure coding practices apply broadly.
What are real-world examples of Dynamic Variable Evaluation?+
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.
What is the difference between a CWE and a CVE?+
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.