CWEweakness

CWE-486 Comparison of Classes by Name

High Official page ↗
Abstraction
Variant
Structure
Simple
Status
Draft
Likelihood of exploit
High
Languages
Java
CWE version
5.0

Description

The product compares classes by name.

Common consequences

• Integrity, Confidentiality, Availability: Execute Unauthorized Code or Commands — The product could use the wrong class. If the decision to trust the methods and data of an object is based on the name of a class, it is possible for malicious users to send objects of the same name as trusted classes and thereby gain the trust afforded to known classes and types.

Potential mitigations

• [Implementation] Use class equivalency to determine type. Rather than use the class name to determine if an object is of a given type, use the getClass() method, and == operator.

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

Related

Child of · CWE (1)

  • CWE-1025 Comparison Using Wrong Factors weakness

Referenced by CWE · has member (1)

Referenced by CWE · peer of (1)

  • CWE-386 Symbolic Name not Mapping to Correct Object weakness