---
title: "CWE-627: Dynamic Variable Evaluation"
url: https://radicalnotion.ai/cwe/cwe-627
type: cwe
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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-627: Dynamic Variable Evaluation

- **Abstraction:** Variant
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 5
- **Of those, in CISA KEV:** 0
- **New in 2026:** 3
- **CWE catalog version:** 4.21

## 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.

## Background

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).

## Alternate terms

- Dynamic evaluation

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | - |

## Applicable platforms

**Languages:** PHP (Undetermined), Perl (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Confidentiality, Integrity, Availability | Modify Application Data, Execute Unauthorized Code or Commands, Varies by Context | An attacker could gain unauthorized read or write access to internal program variables and possibly execute arbitrary code. 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. |

## Potential mitigations

### Implementation (Refactoring)

Refactor the code to avoid dynamic variable evaluation whenever possible.

### Implementation (Input Validation)

Use only allowlists of acceptable variable or function names.

### Implementation

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

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2009-0422 | Chain: Dynamic variable evaluation allows resultant remote file inclusion and path traversal. |
| CVE-2007-2431 | Chain: dynamic variable evaluation in PHP program used to modify critical, unexpected $\_SERVER variable for resultant XSS. |
| CVE-2006-4904 | Chain: dynamic variable evaluation in PHP program used to conduct remote file inclusion. |
| CVE-2006-4019 | Dynamic variable evaluation in mail program allows reading and modifying attachments and preferences of other users. |

## Real CVEs with this weakness

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2024-8953 | Unsafe eval usage in composiohq/composio | critical | 9.8 | - | No | 2025-03-20 |
| CVE-2026-2452 | Unsafe variable evaluation in email templates | high | 7.5 | - | No | 2026-02-16 |
| CVE-2026-2451 | Unsafe variable evaluation in email templates | high | 7.5 | - | No | 2026-02-16 |
| CVE-2026-2415 | Unsafe variable evaluation in email templates | high | 7.5 | - | No | 2026-02-16 |
| CVE-2023-31032 | CVE | high | 7.5 | - | No | 2024-01-12 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-914](https://radicalnotion.ai/cwe/cwe-914) | Improper Control of Dynamically-Identified Variables |
| Peer | [CWE-183](https://radicalnotion.ai/cwe/cwe-183) | Permissive List of Allowed Inputs |

## Frequently asked questions

### What is CWE-627?

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.

### What CVEs are caused by CWE-627?

5 recorded CVEs are attributed to CWE-627, including CVE-2024-8953, CVE-2026-2452 and CVE-2026-2451.

### How do you prevent CWE-627?

Refactor the code to avoid dynamic variable evaluation whenever possible.

### What are the consequences of CWE-627?

Exploiting CWE-627 can lead to: Modify Application Data, Execute Unauthorized Code or Commands, Varies by Context.

### Is CWE-627 actively exploited?

5 recorded CVEs are caused by CWE-627; none are currently in CISA's KEV catalog of actively exploited flaws.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/627.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-627). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
