---
title: "CWE-913: Improper Control of Dynamically-Managed Code Resources"
url: https://radicalnotion.ai/cwe/cwe-913
type: cwe
description: "The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-913: Improper Control of Dynamically-Managed Code Resources

- **Abstraction:** Class
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 81
- **Of those, in CISA KEV:** 1
- **New in 2026:** 25
- **CWE catalog version:** 4.21

## Description

The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.

## Background

Many languages offer powerful features that allow the programmer to dynamically create or modify existing code, or resources used by code such as variables and objects. While these features can offer significant flexibility and reduce development time, they can be extremely dangerous if attackers can directly influence these code resources in unexpected ways.

## Modes of introduction

| Phase | Note |
| --- | --- |
| Architecture and Design | - |
| Implementation | - |

## Applicable platforms

**Languages:** Interpreted (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity | Execute Unauthorized Code or Commands | - |
| Other, Integrity | Varies by Context, Alter Execution Logic | - |

## Potential mitigations

### Implementation (Input Validation)

For any externally-influenced input, check the input against an allowlist of acceptable values.

### Implementation, Architecture and Design (Refactoring)

Refactor the code so that it does not need to be dynamically managed.

## Detection methods

### Fuzzing

Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

Effectiveness: High

## Demonstrative examples

### Example 1

This example attempts to write user messages to a message file and allow users to view them.

Bad code:

```php
$MessageFile = "messages.out";
if ($_GET["action"] == "NewMessage") {
    $name = $_GET["name"];
    $message = $_GET["message"];
    $handle = fopen($MessageFile, "a+");
    fwrite($handle, "<b>$name</b> says '$message'<hr>\n");
    fclose($handle);
    echo "Message Saved!<p>\n";
}
else if ($_GET["action"] == "ViewMessages") {
    include($MessageFile);
}
```

Attack code:

```
name=h4x0r
message=%3C?php%20system(%22/bin/ls%20-l%22);?%3E
```

Attack code:

```
<?php system("/bin/ls -l");?>
```

### Example 2

A common reason that programmers use the reflection API is to implement their own command dispatcher. The following example shows a command dispatcher that does not use reflection:

Good code:

```java
String ctl = request.getParameter("ctl");
Worker ao = null;
if (ctl.equals("Add")) {
    ao = new AddCommand();
}
else if (ctl.equals("Modify")) {
    ao = new ModifyCommand();
}
else {
    throw new UnknownActionError();
}
ao.doAction(request);
```

Bad code:

```java
String ctl = request.getParameter("ctl");
Class cmdClass = Class.forName(ctl + "Command");
Worker ao = (Worker) cmdClass.newInstance();
ao.doAction(request);
```

Bad code:

```java
String ctl = request.getParameter("ctl");
Class cmdClass = Class.forName(ctl + "Command");
Worker ao = (Worker) cmdClass.newInstance();
ao.checkAccessControl(request);
ao.doAction(request);
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2022-2054 | Python compiler uses eval() to execute malicious strings as Python code. |
| CVE-2018-1000613 | Cryptography API uses unsafe reflection when deserializing a private key |
| CVE-2015-8103 | Deserialization issue in commonly-used Java library allows remote execution. |
| CVE-2006-7079 | Chain: extract used for register\_globals compatibility layer, enables path traversal (CWE-22) |
| CVE-2012-2055 | Source version control product allows modification of trusted key using mass assignment. |

## Real CVEs with this weakness (sample of 12 of 81)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2025-68613 | n8n Vulnerable to Remote Code Execution via Expression Injection | critical | 9.4 | - | Yes | 2025-12-19 |
| CVE-2026-92955 | vm2 before 3.11.8 Sandbox Escape via NodeVM | critical | 10.0 | - | No | 2026-09-17 |
| CVE-2026-92946 | vm2 before 3.11.7 Remote Code Execution via require.external | critical | 10.0 | - | No | 2026-09-17 |
| CVE-2026-47208 | vm2: Sandbox Breakout Using Promise Species | critical | 10.0 | - | No | 2026-06-12 |
| CVE-2026-47137 | vm2: GHSA-8hg8-63c5-gwmx patch bypass: nesting:true without explicit require still allows full RCE | critical | 10.0 | - | No | 2026-06-12 |
| CVE-2026-47131 | vm2: Sandbox Escape | critical | 10.0 | - | No | 2026-06-12 |
| CVE-2026-34156 | NocoBase Affected by Sandbox Escape to RCE via console.\_stdout Prototype Chain Traversal in Workflow Script Node | critical | 10.0 | - | No | 2026-03-31 |
| CVE-2023-29199 | vm2 Sandbox escape vulnerability | critical | 10.0 | - | No | 2023-04-14 |
| CVE-2023-29017 | vm2 Sandbox Escape vulnerability | critical | 10.0 | - | No | 2023-04-06 |
| CVE-2022-36067 | vm2 vulnerable to Sandbox Escape before v3.9.11 | critical | 10.0 | - | No | 2022-09-06 |
| CVE-2025-46673 | - | critical | 9.9 | - | No | 2025-04-27 |
| CVE-2024-27135 | Apache Pulsar: Improper Input Validation in Pulsar Function Worker allows Remote Code Execution | critical | 9.9 | - | No | 2024-03-12 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-664](https://radicalnotion.ai/cwe/cwe-664) | Improper Control of a Resource Through its Lifetime |
| Child | [CWE-94](https://radicalnotion.ai/cwe/cwe-94) | Improper Control of Generation of Code |
| Child | [CWE-470](https://radicalnotion.ai/cwe/cwe-470) | Use of Externally-Controlled Input to Select Classes or Code |
| Child | [CWE-502](https://radicalnotion.ai/cwe/cwe-502) | Deserialization of Untrusted Data |
| Child | [CWE-914](https://radicalnotion.ai/cwe/cwe-914) | Improper Control of Dynamically-Identified Variables |
| Child | [CWE-915](https://radicalnotion.ai/cwe/cwe-915) | Improperly Controlled Modification of Dynamically-Determined Object Attributes |
| Child | [CWE-1321](https://radicalnotion.ai/cwe/cwe-1321) | Improperly Controlled Modification of Object Prototype Attributes |

## Frequently asked questions

### What is CWE-913?

The product does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.

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

81 recorded CVEs are attributed to CWE-913, including CVE-2025-68613, CVE-2026-92955 and CVE-2026-92946. 1 is listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How do you prevent CWE-913?

For any externally-influenced input, check the input against an allowlist of acceptable values.

### How is CWE-913 detected?

Fuzzing: Fuzz testing (fuzzing) is a powerful technique for generating large numbers of diverse inputs - either randomly or algorithmically - and dynamically invoking the code with those inputs. Even with random inputs, it is often capable of generating unexpected results such as crashes, memory corruption, or resource consumption. Fuzzing effectively produces repeatable test cases that clearly indicate bugs, which helps developers to diagnose the issues.

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

Exploiting CWE-913 can lead to: Execute Unauthorized Code or Commands, Varies by Context, Alter Execution Logic.

### Is CWE-913 actively exploited?

Yes. 1 CWE-913 vulnerability is in CISA's KEV catalog of actively exploited flaws, out of 81 recorded CVEs.

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

---

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