---
title: "CWE-470: Use of Externally-Controlled Input to Select Classes or Code"
url: https://radicalnotion.ai/cwe/cwe-470
type: cwe
description: "The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-470: Use of Externally-Controlled Input to Select Classes or Code

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Draft
- **CVEs with this as primary weakness:** 137
- **Of those, in CISA KEV:** 2
- **New in 2026:** 96
- **CWE catalog version:** 4.21

## Description

The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.

An attacker could supply values to select unexpected classes or methods. If this occurs, then the attacker could create control flow paths that were not intended by the developer. These paths could bypass authentication or access control checks, or otherwise cause the product to behave in an unexpected manner. This situation becomes a doomsday scenario if the attacker can upload files into a location that appears on the product's classpath (CWE-427) or add new entries to the product's classpath (CWE-426). Under either of these conditions, the attacker can use reflection to introduce new, malicious behavior into the product.

## Alternate terms

- Reflection Injection
- Unsafe Reflection

## Applicable platforms

**Languages:** Java (Undetermined), PHP (Undetermined), Interpreted (Sometimes)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Integrity, Confidentiality, Availability, Other | Execute Unauthorized Code or Commands, Alter Execution Logic | The attacker might be able to execute code that is not directly accessible to the attacker. Alternately, the attacker could call unexpected code in the wrong place or the wrong time, possibly modifying critical system state. |
| Availability, Other | DoS: Crash, Exit, or Restart, Other | The attacker might be able to use reflection to call the wrong code, possibly with unexpected arguments that violate the API (CWE-227). This could cause the product to exit or hang. |
| Confidentiality | Read Application Data | By causing the wrong code to be invoked, the attacker might be able to trigger a runtime error that leaks sensitive information in the error message, such as CWE-536. |

## Potential mitigations

### Architecture and Design

Refactor your code to avoid using reflection.

### Architecture and Design

Do not use user-controlled inputs to select and load classes or code.

### Implementation

Apply strict input validation by using allowlists or indirect selection to ensure that the user is only selecting allowable classes or code.

## Detection methods

### Automated Static Analysis

Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

Effectiveness: High

## Demonstrative examples

### Example 1

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-2018-1000613 | Cryptography API uses unsafe reflection when deserializing a private key |
| CVE-2004-2331 | Database system allows attackers to bypass sandbox restrictions by using the Reflection API. |

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

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2026-90436 | Apache Axis 1.x (EOL): unauthenticated remote class instantiation via SOAP fault exceptionName | critical | 9.8 | - | Yes | 2026-11-06 |
| CVE-2026-82078 | PaperCut MF/NG: Unsafe Dynamic Class Loading in Database Connector | critical | 9.4 | - | Yes | 2026-08-28 |
| CVE-2026-73098 | Apache Juneau: Unsafe reflection allows attacker-controlled class initialization during parsing | critical | 10.0 | - | No | 2026-11-05 |
| CVE-2025-34393 | Barracuda RMM \< 2025.1.1 Service Center Insecure Reflection RCE | critical | 10.0 | - | No | 2025-12-10 |
| CVE-2026-115931 | Arbitrary file read and backend crash through unrestricted provider method calls | critical | 9.9 | - | No | 2026-10-23 |
| CVE-2026-13772 | IBM WebSphere eXtreme Scale's OQL is affected by remote code execution | critical | 9.9 | - | No | 2026-06-30 |
| CVE-2026-16306 | CVE-2026-16306 | critical | 9.8 | - | No | 2026-11-02 |
| CVE-2026-71253 | Apache Johnzon: ClassConverter loads & static-initializes an attacker-named class from untrusted JSON | critical | 9.8 | - | No | 2026-10-19 |
| CVE-2026-78030 | DBI versions before 1.653 for Perl load arbitrary modules via unvalidated dbm\_type and dbm\_mldbm attributes in DBD::DBM | critical | 9.8 | - | No | 2026-09-19 |
| CVE-2026-8400 | Multiple Vulnerabilities in IBM® Java SDK affect IBM WebSphere Application Server and WebSphere Application Server Liberty due to the July 2026 CPU | critical | 9.8 | - | No | 2026-08-05 |
| CVE-2026-40008 | Apache IoTDB: Arbitrary Class Instantiation via Pipe Transfer RPC | critical | 9.8 | - | No | 2026-07-10 |
| CVE-2026-42027 | Apache OpenNLP: Arbitrary Class Instantiation via Model Manifest in ExtensionLoader | critical | 9.8 | - | No | 2026-05-04 |

## Related attack patterns (CAPEC)

- [CAPEC-138](https://radicalnotion.ai/capec/capec-138): Reflection Injection

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-20](https://radicalnotion.ai/cwe/cwe-20) | Improper Input Validation |
| Parent | [CWE-610](https://radicalnotion.ai/cwe/cwe-610) | Externally Controlled Reference to a Resource in Another Sphere |
| Parent | [CWE-913](https://radicalnotion.ai/cwe/cwe-913) | Improper Control of Dynamically-Managed Code Resources |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| 7 Pernicious Kingdoms | Unsafe Reflection | - | - |
| The CERT Oracle Secure Coding Standard for Java (2011) | Do not use reflection to increase accessibility of classes, methods, or fields | SEC06-J | - |

## Frequently asked questions

### What is CWE-470?

The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.

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

137 recorded CVEs are attributed to CWE-470, including CVE-2026-90436, CVE-2026-82078 and CVE-2026-73098. 2 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How do you prevent CWE-470?

Refactor your code to avoid using reflection.

### How is CWE-470 detected?

Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)

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

Exploiting CWE-470 can lead to: Execute Unauthorized Code or Commands, Alter Execution Logic, DoS: Crash, Exit, or Restart, Other, Read Application Data.

### Is CWE-470 actively exploited?

Yes. 2 CWE-470 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 137 recorded CVEs.

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

---

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