[Forgot Password]
Login  Register Subscribe

23631

 
 

115084

 
 

97147

 
 

909

 
 

78730

 
 

109

Paid content will be excluded from the download.


Download | Alert*
CWE
view XML

Access of Resource Using Incompatible Type ('Type Confusion')

ID: 843Date: (C)2012-05-14   (M)2012-11-08
Type: weaknessStatus: INCOMPLETE
Abstraction Type: Base





Description

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 Description

When 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 Platforms
Language: C
Language: C++
Language Class: Language-independent
Language Class: Type-unsafe Languages

Time Of Introduction

  • Implementation

Common Consequences
None

Detection Methods
None

Potential Mitigations
None

Relationships

Related CWETypeViewChain
CWE-843 CanPrecede CWE-119 Weakness CWE-1000  

Demonstrative Examples   (Details)

  1. The following PHP code accepts a value, adds 5, and prints the sum.
  2. 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).
  3. The following code uses a union to support the representation of different types of messages. It formats messages differently, depending on their type.

Observed Examples

  1. CVE-2010-4577 : Type confusion in CSS sequence leads to out-of-bounds read.
  2. CVE-2011-0611 : Size inconsistency allows code execution, first discovered when it was actively exploited in-the-wild.
  3. 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

Taxynomy Mappings
None

References:

  1. Mark Dowd Ryan Smith David Dewey .Attacking Interoperability. Section:'"Type Confusion Vulnerabilities," page 59'. Published on 2009.
  2. 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.

© 2013 SecPod Technologies