---
title: "CWE-843: Access of Resource Using Incompatible Type"
url: https://radicalnotion.ai/cwe/cwe-843
type: cwe
description: "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."
updated: 2026-11-10
source: RadicalNotion.AI
license: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
---

# CWE-843: Access of Resource Using Incompatible Type

- **Abstraction:** Base
- **Structure:** Simple
- **Status:** Incomplete
- **CVEs with this as primary weakness:** 1,122
- **Of those, in CISA KEV:** 43
- **New in 2026:** 440
- **CWE catalog version:** 4.21

## Description

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.

## Alternate terms

- Type Confusion
- Object Type Confusion

## Modes of introduction

| Phase | Note |
| --- | --- |
| Implementation | This weakness is not unique to C and C++. While it 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. 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. |

## Applicable platforms

**Languages:** C (Undetermined), C++ (Undetermined), Python (Undetermined)

## Common consequences

| Scope | Impact | Note |
| --- | --- | --- |
| Other | Varies by Context | When the product accesses the resource using an incompatible type, this could trigger logical errors because the resource does not have expected properties. |
| Availability, Integrity, Confidentiality | Read Memory, Modify Memory, Execute Unauthorized Code or Commands, DoS: Crash, Exit, or Restart | 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. |

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

Effectiveness: High

## Demonstrative examples

### Example 1

The following code uses a union to support the representation of different types of messages. It formats messages differently, depending on their type.

Bad code:

```c
#define NAME_TYPE 1
#define ID_TYPE 2

struct MessageBuffer
{
    int msgType;
    union {
        char *name;
        int nameID;
    };
};

int main (int argc, char **argv) {
    struct MessageBuffer buf;
    char *defaultMessage = "Hello World";

    buf.msgType = NAME_TYPE;
    buf.name = defaultMessage;
    printf("Pointer of buf.name is %p\n", buf.name);
    /* This particular value for nameID is used to make the code architecture-independent. If coming from untrusted input, it could be any value. */

    buf.nameID = (int)(defaultMessage + 1);
    printf("Pointer of buf.name is now %p\n", buf.name);
    if (buf.msgType == NAME_TYPE) {
        printf("Message: %s\n", buf.name);
    }
    else {
        printf("Message: Use ID %d\n", buf.nameID);
    }
}
```

### Example 2

The following PHP code accepts a value, adds 5, and prints the sum.

Bad code:

```php
$value = $_GET['value'];
$sum = $value + 5;
echo "value parameter is '$value'<p>";
echo "SUM is $sum";
```

### Example 3

The following Perl code is intended to look up the privileges for user ID's between 0 and 3, by rreading an element of the $UserPrivilegeArray reference. It is expected that only userID 3 is an admin (since this is listed in the third element of the array).

Bad code:

```perl
my $UserPrivilegeArray = ["user", "user", "admin", "user"];

my $userID = get_current_user_ID();

if ($UserPrivilegeArray eq "user") {
    print "Regular user!\n";
}
else {
    print "Admin!\n";
}

print "\$UserPrivilegeArray = $UserPrivilegeArray\n";
```

## Observed examples

| CVE | Description |
| --- | --- |
| CVE-2025-32352 | Type confusion in PHP app allows authentication bypass when users have passwords whose MD5 hashes can be interpreted as numbers |
| CVE-2010-4577 | Type confusion in CSS sequence leads to out-of-bounds read. |
| CVE-2011-0611 | Size inconsistency allows code execution, first discovered when it was actively exploited in-the-wild. |
| CVE-2010-0258 | Improperly-parsed file containing records of different types leads to code execution when a memory location is interpreted as a different object than intended. |

## Real CVEs with this weakness (sample of 12 of 1,122)

| CVE | Title | Severity | CVSS | EPSS | CISA KEV | Published |
| --- | --- | --- | --- | --- | --- | --- |
| CVE-2017-0037 | Microsoft Edge and Internet Explorer Type Confusion Vulnerability | critical | 10.0 | - | Yes | 2017-02-26 |
| CVE-2024-4947 | Google Chromium V8 Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2024-05-15 |
| CVE-2024-23222 | Apple Multiple Products WebKit Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2024-01-23 |
| CVE-2023-3079 | Google Chromium V8 Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2023-06-05 |
| CVE-2022-42856 | Apple iOS Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2022-12-15 |
| CVE-2020-6418 | Google Chromium V8 Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2020-02-27 |
| CVE-2019-11707 | Mozilla Firefox and Thunderbird Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2019-07-23 |
| CVE-2018-8298 | ChakraCore Scripting Engine Type Confusion Vulnerability | critical | 9.4 | - | Yes | 2018-07-11 |
| CVE-2012-0507 | Oracle Java SE Runtime Environment (JRE) Arbitrary Code Execution Vulnerability | critical | 9.4 | - | Yes | 2012-06-07 |
| CVE-2021-30869 | iOS and iPadOS: XNU - A malicious application may be able to execute arbitrary code with kernel privileges | critical | 9.3 | - | Yes | 2021-08-24 |
| CVE-2017-8291 | Artifex Ghostscript Type Confusion Vulnerability | critical | 9.3 | - | Yes | 2017-04-27 |
| CVE-2019-0752 | Microsoft Internet Explorer Type Confusion Vulnerability | critical | 9.0 | - | Yes | 2019-04-09 |

## Related weaknesses

| Relationship | CWE | Name |
| --- | --- | --- |
| Parent | [CWE-704](https://radicalnotion.ai/cwe/cwe-704) | Incorrect Type Conversion or Cast |
| Peer | [CWE-1287](https://radicalnotion.ai/cwe/cwe-1287) | Improper Validation of Specified Type of Input |
| Can precede | [CWE-119](https://radicalnotion.ai/cwe/cwe-119) | Improper Restriction of Operations within the Bounds of a Memory Buffer |

## Taxonomy mappings

| Taxonomy | Entry | Id | Fit |
| --- | --- | --- | --- |
| CERT C Secure Coding | Do not access a variable through a pointer of an incompatible type | EXP39-C | Exact |
| OpenSSF Secure Coding Guide for Python | Prevent Type Confusion | pyscg-0011 | - |

## Frequently asked questions

### What is 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.

### What CVEs are caused by CWE-843?

1,122 recorded CVEs are attributed to CWE-843, including CVE-2017-0037, CVE-2024-4947 and CVE-2024-23222. 43 are listed in CISA's Known Exploited Vulnerabilities (KEV) catalog.

### How is CWE-843 detected?

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

### What are the consequences of CWE-843?

Exploiting CWE-843 can lead to: Varies by Context, Read Memory, Modify Memory, Execute Unauthorized Code or Commands, DoS: Crash, Exit, or Restart.

### Is CWE-843 actively exploited?

Yes. 43 CWE-843 vulnerabilities are in CISA's KEV catalog of actively exploited flaws, out of 1,122 recorded CVEs.

Primary source: [MITRE CWE](https://cwe.mitre.org/data/definitions/843.html)

---

Source: [RadicalNotion.AI](https://radicalnotion.ai/cwe/cwe-843). Licensed CC BY-NC 4.0; attribute RadicalNotion.AI and link the source page when you reuse this data.
