What Is Unsafe Reflection? CWE-470 Explained
Security Beginner 4 min read

What Is Unsafe Reflection? CWE-470 Explained

Unsafe reflection (CWE-470) lets outside input choose which class an app loads. Learn how it leads to code execution and how to prevent it in Java.

Published: November 17, 2026 • Updated: November 17, 2026
unsafe reflectioncwe-470javasecure coding

Unsafe reflection is a weakness where an application lets outside input decide which class or method it loads and runs. MITRE tracks it as CWE-470, "use of externally controlled input to select classes or code." When an attacker can name the class, the application ends up running code the developer never meant to expose. The November 2026 Apache Axis flaw behind the Confluence CVE-2026-90436 exploitation is a current example.

What is unsafe reflection?

Unsafe reflection is the use of attacker-controlled text, such as a class name in a request, to choose which code the program loads or instantiates. It turns a data field into a way to pick code paths.

Reflection itself is a normal language feature. In Java, a program can take a string like a class name, ask the runtime to load that class, and create an instance of it without that class appearing anywhere in the source code that calls it. Frameworks rely on this for plugins, dependency injection, serialization and configuration files.

The problem starts when the string comes from someone you do not trust.

How does unsafe reflection lead to code execution?

Loading a class is not a passive act. In Java, the first time a class is loaded and initialized, its static initializer runs. Creating an instance runs a constructor. If an attacker can name any class on the application's classpath, they can trigger those code paths with arguments they also control.

On its own, that might only cause errors. The danger comes from the classpath. Large Java applications ship hundreds of libraries, and some of those libraries contain classes whose constructors or initializers do something useful to an attacker: open a connection, read a file, evaluate an expression or start a process. Security researchers call these gadgets. The attacker does not need to upload code. They point the application at code it already has.

That is why exploitability varies by product. The same weakness in a library can be harmless in a small application and critical in a large one with the right gadgets available.

A real example: Apache Axis 1.x

Apache Axis 1.x is an end-of-life Java engine for SOAP web services. According to the CVE record for CVE-2026-90436, when Axis receives a SOAP fault that carries an exceptionName element, it loads the named class and, if a string data element is present, instantiates it through its string constructor. Only after that does it check whether the class is the fault type it expected.

Two design choices made this worse:

  • The check came too late. Validation happened after loading and instantiation, so the side effects had already run.
  • It ran before authentication. Axis parsed the fault while still deciding which service the request targeted, before any per-service authentication handler. An unauthenticated request was enough.

The result scored CVSS 3.1 9.8 in the CISA enrichment and 9.3 under CVSS 4.0 in Atlassian's rating, and it was exploited against Confluence Data Center servers that had the Remote API enabled.

How is unsafe reflection different from insecure deserialization?

Insecure deserialization rebuilds whole objects from attacker-supplied bytes, and unsafe reflection lets the attacker pick a class by name. They overlap heavily, and many deserialization bugs are exploitable precisely because the format lets the input name its own classes.

For defenders the practical difference is small. Both turn a parser into a code loader, both depend on gadget classes already present, and both are fixed the same way: stop letting input choose classes.

How do you prevent unsafe reflection?

Developers and reviewers should look for these patterns:

  1. Use an allowlist, not a denylist. If input must select a class, map a short set of known names to known classes. Never pass the raw string to the class loader.
  2. Validate before loading. Check the requested type against the expected base type using metadata, before the class is loaded or initialized. Checking after instantiation is too late.
  3. Authenticate before parsing complex input. Any parser that can load classes should sit behind authentication, not in front of it.
  4. Shrink the classpath. Remove libraries the application does not use. Fewer classes means fewer gadgets.
  5. Retire unsupported frameworks. Axis 1.x will not receive an official fix. Apache recommends moving to Axis 2 or applying its patch to a custom build.

What can operations teams do without touching code?

Most sysadmins cannot change how a vendor product loads classes. You can control whether the vulnerable code path is reachable:

  • Turn off features that expose the parser. For Confluence, that is the Remote API setting, which we cover in how to disable the Confluence Remote API safely.
  • Keep management and API endpoints off the internet unless a business need is documented.
  • Track which products embed old frameworks. A component inventory makes it faster to answer "do we run Axis 1.x anywhere" on the day a CVE drops.
  • Treat optional legacy interfaces as risk, as covered in why you should switch off unused legacy APIs.

Spotting unsafe reflection in advisories

Vendor advisories rarely say "reflection." Watch for these phrases, which usually point to the same class of bug:

  • CWE-470, CWE-502 or "unsafe reflection" in the CVE record
  • "remote class instantiation" or "arbitrary class loading"
  • "deserialization of untrusted data"
  • "exploitability depends on classes available on the classpath"

When you see them in a Java product, assume unauthenticated code execution is possible until the vendor says otherwise, and prioritize accordingly.