COMMON ATTACK PATTERN ENUMERATION AND CLASSIFICATIONLive MITRE record

CAPEC-92

Forced Integer Overflow

This attack forces an integer variable to go out of range. The integer variable is often used as an offset such as size of memory allocation or similarly. The attacker would typically control the value of such variable and try to get it out of range. For instance the integer in question is incremented past the maximum possible value, it may wrap to become a very small, or negative number, therefore providing a very incorrect value which can lead to unexpected behavior. At worst the attacker can execute arbitrary code.

Abstraction

Detailed

Typical severity

High

Likelihood of attack

High

Understand the attack

What is this attack pattern?

This attack forces an integer variable to go out of range. The integer variable is often used as an offset such as size of memory allocation or similarly. The attacker would typically control the value of such variable and try to get it out of range. For instance the integer in question is incremented past the maximum possible value, it may wrap to become a very small, or negative number, therefore providing a very incorrect value which can lead to unexpected behavior. At worst the attacker can execute arbitrary code.

Execution flow

How does the attack proceed, step by step?

1

Explore

Attack step

The first step is exploratory meaning the attacker looks for an integer variable that they can control.
2

Experiment

Attack step

The attacker finds an integer variable that they can write into or manipulate and try to get the value of the integer out of the possible range.
3

Exploit

Attack step

The integer variable is forced to have a value out of range which set its final value to an unexpected value.

Attack step

The target host acts on the data and unexpected behavior may happen.

Requirements

What does the attack require?

Prerequisites

  • The attacker can manipulate the value of an integer variable utilized by the target host.
  • The target host does not do proper range checking on the variable before utilizing it.
  • When the integer variable is incremented or decremented to an out of range value, it gets a very different value (e.g. very small or negative number)

Skills required

  • Low: An attacker can simply overflow an integer by inserting an out of range value.
  • High: Exploiting a buffer overflow by injecting malicious code into the stack of a software system or even the heap can require a higher skill level.

Resources required

Not stated in the MITRE record.

Impact

What does a successful attack lead to?

Modify Data

Affected scopes: Integrity

Gain Privileges

Affected scopes: Confidentiality, Access Control, Authorization

Execute Unauthorized Commands

Affected scopes: Confidentiality, Integrity, Availability

Read Data

Affected scopes: Confidentiality

Unreliable Execution

Affected scopes: Availability

Defence

How is it prevented and mitigated?

1
Use a language or compiler that performs automatic bounds checking.
2
Carefully review the service's implementation before making it available to user. For instance you can use manual or automated code review to uncover vulnerabilities such as integer overflow.
3
Use an abstraction library to abstract away risky APIs. Not a complete solution.
4
Always do bound checking before consuming user input data.

Real world

MITRE example instances

Example instance 1Detail
Integer overflow in the ProcAuWriteElement function in server/dia/audispatch.c in Network Audio System (NAS) before 1.8a SVN 237 allows remote attackers to cause a denial of service (crash) and possibly execute arbitrary code via a large max_samples value. See also: CVE-2007-1544
Example instance 2Detail
The following code illustrates an integer overflow. The declaration of total integer as "unsigned short int" assumes that the length of the first and second arguments fits in such an integer [ REF-547 ], [ REF-548 ]. include <stdlib.h> include <string.h> include <stdio.h> int main (int argc, char *const *argv) { if (argc !=3){ printf("Usage: prog_name <string1> <string2>\n"); exit(-1); } unsigned short int total; total = strlen(argv[1])+strlen(argv[2])+1; char * buff = (char *)malloc(total); strcpy(buff, argv[1]); strcpy(buff, argv[2]); }
CAPEC-92: Forced Integer Overflow — DayBreach Saldırı Sözlüğü · DayBreach