Backslash Vulnerability Database Dynamic Variable Evaluation
Dynamic Variable Evaluation
CWE-627
Short description
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.
Extended 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.
Best practices to prevent this CWE
Phase: Implementation
Strategy: Refactoring
Refactor the code to avoid dynamic variable evaluation whenever possible.
Phase: Implementation
Strategy: Input Validation
Use only allowlists of acceptable variable or function names.
Phase: Implementation
For function names, ensure that you are only calling functions that accept the proper number of arguments, to avoid unexpected null arguments.