CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')

What is CWE-843?

CWE-843 is Access of Resource Using Incompatible Type ('Type Confusion'). The flaw arises when the product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. The database currently holds 171 vulnerabilities mapped to CWE-843 and 2 of them are in the CISA Known Exploited Vulnerabilities catalog.

Analyzing data...

OWASP Top 10 Rank-
Related CVES (365 days)171
AbstractionBase
Likelihood of exploit-

Vulnerabilities mapped to CWE-843

171 vulnerabilities217% increase year over year

Vulnerabilities in CISA KEV for CWE-843

2 vulnerabilities100% increase year over year

Official definition

ByMitre CWE

The product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type.

When the product accesses the resource using an incompatible type, this could trigger logical errors because the resource does not have expected properties. In languages without memory safety, such as C and C++, type confusion can lead to out-of-bounds memory access.

While this weakness is frequently associated with unions when parsing data with many different embedded object types in C, it can be present in any application that can interpret the same variable or memory location in multiple ways.

This weakness is not unique to C and C++. For example, errors in PHP applications can be triggered by providing array parameters when scalars are expected, or vice versa. Languages such as Perl, which perform automatic conversion of a variable of one type when it is accessed as if it were another type, can also contain these issues.

Characteristics

Alternate terms

  • Object Type Confusion

Modes of introduction

  • Implementation

Common consequences

ImpactScopeExplanation
Read Memory, Modify Memory, Execute Unauthorized Code or Commands, DoS: Crash, Exit, or RestartAvailability, Integrity, ConfidentialityWhen a memory buffer is accessed using the wrong type, it could read or write memory out of the bounds of the buffer, if the allocated buffer is smaller than the type that the code is attempting to access, leading to a crash and possibly code execution.

Detection methods

MethodApproachEffectiveness
Automated Static AnalysisAutomated 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.)High

Representative vulnerabilities

Sources (2)

CWE™ Program, operated by The MITRE Corporation. Copyright © 2006–2026, The MITRE Corporation. The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. CWE Terms of Use.

Learn more

Run an in-depth assessment with complete web risk management

CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.