What is CWE-843?
CWE-843 is Access of Resource Using Incompatible Type. The flaw arises when the product allocates or initializes a resource, such as a pointer, object, or variable, with one type and later accesses it using an incompatible type.
CWE-843 is Access of Resource Using Incompatible Type. The flaw arises when the product allocates or initializes a resource, such as a pointer, object, or variable, with one type and later accesses it using an incompatible type.
No vulnerability data for CWE-843
No vulnerability data in CISA KEV for CWE-843
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. (Roles: Common-Name, Common-Name)
When the later access type is incompatible with the type used for allocation or initialization, the program may misinterpret the resource's structure, size, or properties. If a memory buffer is accessed through a type larger than the allocated buffer, the access can extend beyond the buffer's bounds. The weakness can occur across different languages and data models, not only in C or C++ code involving casts or unions.
This weakness occurs when the same resource or memory location is interpreted through incompatible types, so the properties expected by the code do not match the actual data. It is often associated with unions and parsing data that contains multiple embedded object types in C, but it is not limited to C or C++; similar problems can arise when an application treats array parameters as scalars or vice versa, or when a language automatically converts a variable while it is accessed as another type. The record identifies C, C++, and Python as applicable languages, with prevalence undetermined.
The immediate result may be a logical error because the resource does not have the expected properties. If an allocated buffer is smaller than the incompatible type used to access it, an attacker may be able to read or modify memory outside the buffer, potentially causing a crash, unauthorized code or command execution, or impacts to confidentiality, integrity, and availability.
| Impact | Scope | Explanation |
|---|---|---|
| Varies by Context | Other | When the product accesses the resource using an incompatible type, this could trigger logical errors because the resource does not have expected properties. |
| Read Memory, Modify Memory, Execute Unauthorized Code or Commands, DoS: Crash, Exit, or Restart | Availability, Integrity, Confidentiality | If a memory buffer is accessed using an incompatible type, and the allocated buffer is smaller than the type that the code is attempting to access, then an attacker could read or write memory outside the bounds of the buffer, leading to a crash or possibly code execution. |
The official record does not specify mitigation guidance for this weakness.
Automated static analysis, commonly known as Static Application Security Testing (SAST), can detect some instances by analyzing source code or binary/compiled code without executing it. It typically builds data-flow and control-flow models, then searches for potentially vulnerable patterns connecting sources, where input originates, to sinks, where data interacts with external components or a lower layer such as the operating system. The official record rates this approach as highly effective, but it applies only to some instances of the weakness.
| Method | Approach | Effectiveness |
|---|---|---|
| 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.) | High |
The following are representative examples, not an exhaustive list:
CVE-2025-32352: Type confusion in a PHP application allows authentication bypass when users have passwords whose MD5 hashes can be interpreted as numbers.CVE-2010-4577: Type confusion in a CSS sequence leads to an out-of-bounds read.CVE-2011-0611: A size inconsistency leads to code execution; the issue was first discovered while it was being actively exploited in the wild.CVE-2010-0258: An improperly parsed file containing records of different types causes a memory location to be interpreted as an unintended object, leading to code execution.Below are representative vulnerabilities related to this CWE, prioritized by severity.
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.
CyStack VulnScan continuously discovers assets, validates vulnerabilities, and helps security teams prioritize remediation across the organization.
Review CyStack's security rating and practical recommendations for websites and edge assets.
Explore cybersecurity research from our team of security specialists.
Browse practical cybersecurity knowledge across CyStack's articles and guides.
en