CWEweakness

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

Official page ↗
Alternate terms
Reflection Injection, Unsafe Reflection
Abstraction
Base
Structure
Simple
Status
Draft
Languages
Interpreted, Java, PHP
CWE version
5.0

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.

Extended description

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.

Common consequences

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

Observed examples

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

Related

Attack pattern · CAPEC (1)

  • CAPEC-138 Reflection Injection attack pattern

Observed example · CVE (2)

  • CVE-2018-1000613 Legion of the Bouncy Castle Legion of the Bouncy Castle Java Cryptography APIs 1.58 up to but not including 1.60 contains a CWE-470: Use of… vulnerability
  • CVE-2004-2331 ColdFusion MX 6.1 and 6.1 J2EE allows local users to bypass sandbox security restrictions and obtain sensitive information by using Java… vulnerability

Child of · CWE (3)

  • CWE-20 Improper Input Validation weakness
  • CWE-610 Externally Controlled Reference to a Resource in Another Sphere weakness
  • CWE-913 Improper Control of Dynamically-Managed Code Resources weakness

Referenced by CAPEC · weakness (1)

  • CAPEC-138 Reflection Injection attack pattern

Referenced by CVE · weakness (138)

  • CVE-2026-119050 Agno through 3.1.11 contains an unsafe reflection vulnerability in PandasTools that allows attackers to invoke arbitrary pandas functions… vulnerability
  • CVE-2026-116692 MLflow is an open source AI engineering platform for agents, large language models, and machine learning models. vulnerability
  • CVE-2026-115749 hydra-ray-launcher 1.1.0.dev1 before 1.2.2 and 1.4.0.dev4 before 1.4.0rc2 contains an arbitrary module import vulnerability via the… vulnerability
  • CVE-2026-115886 MLflow is an open source AI engineering platform for agents, large language models, and machine learning models. vulnerability
  • CVE-2026-115931 Postiz lets a signed-in user ask the backend to run a function on one of their connected channels. vulnerability
  • CVE-2026-111851 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') vulnerability in WProyal Royal Elementor Addons… vulnerability
  • CVE-2026-114660 Grav from 2.0.0 before 2.2.5 contains an improper access control vulnerability in FlexDirectory::dynamicFlexField() that allows page… vulnerability
  • CVE-2026-114508 Laravel is a web application framework. vulnerability
  • CVE-2026-92206 CrewAI crewAI Framework Agent Loading Unsafe Reflection Remote Code Execution Vulnerability. vulnerability
  • CVE-2026-111440 在 openGauss-connector-jdbc 的 pgjdbc/src/main/java/org/postgresql/log/LogFactory.java 中,LogFactory 根据 JDBC 连接参数中的 logger 类名调用 Class.forName… vulnerability
  • CVE-2026-112075 A weakness has been identified in unslothai unsloth up to 0.1.501-beta. vulnerability
  • CVE-2026-112145 A security vulnerability has been detected in speaches-ai speaches up to 0.9.0-rc.3. vulnerability
  • CVE-2026-71253 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') vulnerability in Apache Johnzon. vulnerability
  • CVE-2026-55543 TuxGuitar is an open-source guitar tablature editor. vulnerability
  • CVE-2026-97666 Sonatype Nexus Repository 3 allows an unauthenticated remote attacker to supply attacker-controlled input to a Java class loading call… vulnerability
  • CVE-2026-104629 A component loading mechanism in openPDC and openHistorian will construct and run any specified type, which may be an invalid component to… vulnerability
  • CVE-2026-106510 Backstage is an open framework for building developer portals. vulnerability
  • CVE-2026-92415 — Use of Externally-Controlled Input to Select Classes or Code vulnerability in Apache Jackrabbit's WebDAV/Davex client. vulnerability
  • CVE-2026-105782 Scrapy is a high-level web crawling and scraping framework for Python. vulnerability
  • CVE-2026-106439 Hydra is a framework for elegantly configuring complex applications. vulnerability
  • CVE-2026-106440 Hydra is a framework for elegantly configuring complex applications. vulnerability
  • CVE-2017-20285 YAML versions before 1.30 for Perl allow a loaded document to trigger the DESTROY method of arbitrary classes. vulnerability
  • CVE-2026-105064 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') vulnerability in Unlimited Elements Unlimited Elements… vulnerability
  • CVE-2026-102094 Kiteworks Email Protection Gateway before version 9.5.0 is vulnerable to Unsafe Reflection and does not sufficiently restrict the code that… vulnerability
  • CVE-2026-102580 A flaw was found in Moodle. vulnerability
  • CVE-2026-55107 Kobako is a Ruby gem that embeds a Wasm-isolated mruby interpreter inside applications, allowing execution of untrusted Ruby scripts… vulnerability
  • CVE-2026-100308 Deserialization of untrusted data in the model loading component in Amazon GluonTS before 0.17.0 might allow context-dependent attackers to… vulnerability
  • CVE-2026-101292 Apache ActiveMQ Artemis before 2.34.0 contains an unsafe reflection vulnerability in FederationStreamConnectMessage.getFederationPolicy(). vulnerability
  • CVE-2026-96740 A flaw was found in the StreamsHub Console for Apache Kafka. vulnerability
  • CVE-2026-96672 Frappe ERPNext versions before 16.34.1 fail to validate that Financial Report Template calculation_formula values reference whitelisted… vulnerability
Show all 138 ›

Referenced by CWE · has member (1)

Referenced by OWASP · mapped cwe (2)