Access of Resource Using Incompatible Type ('Type Confusion')
|ID: 843||Date: (C)2012-05-14 (M)2012-11-08|
|Type: weakness||Status: INCOMPLETE|
|Abstraction Type: Base|
The program 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.
Extended DescriptionWhen the program 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.
Applicable PlatformsLanguage: CLanguage: C++Language Class: Language-independentLanguage Class: Type-unsafe Languages
Time Of Introduction
|CWE-843 CanPrecede CWE-119 ||Weakness ||CWE-1000 || |
Demonstrative Examples (Details)
- The following PHP code accepts a value, adds 5, and prints the
- The following Perl code is intended to look up the privileges for
user ID's between 0 and 3, by performing an access 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).
- The following code uses a union to support the representation of
different types of messages. It formats messages differently, depending on
- 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.
For more examples, refer to CVE relations in the bottom box.
White Box Definitions None
Black Box Definitions None
- Mark Dowd Ryan Smith David Dewey .Attacking Interoperability. Section:'"Type Confusion Vulnerabilities," page 59'. Published on 2009.
- Mark Dowd John McDonald Justin Schuh .The Art of Software Security Assessment 1st Edition. Addison Wesley. Section:'Chapter 7, "Type Confusion", Page 319.'. Published on 2006.