CAPEC

Common Attack Pattern Enumeration and Classification
Common Attack Pattern Enumeration and Classification

A Community Knowledge Resource for Building Secure Software

Home > CAPEC List > Individual CAPEC Dictionary Definition (Release 1.1)   View the CAPEC List

Individual CAPEC Dictionary Definition (Release 1.1)
Individual CAPEC Dictionary Definition (Release 1.1)

Leveraging Race Conditions
Attack Pattern ID
Pattern Abstraction: Standard

26

Typical Severity

High

Description

Summary

This attack targets a race condition occurring when multiple processes access and manipulate the same resource concurrently and the outcome of the execution depends on the particular order in which the access takes place. The attacker can leverage a race condition by "running the race", modifying the resource and modifying the normal execution flow. For instance a race condition can occur while accessing a file, the attacker can trick the system by replacing the original file with his version and cause the system to read the malicious file.

Attack Execution Flow

  1. The attacker explores to gauge what level of access he has.

  2. The attacker gains access to a resource on the target host. The attacker modifies the targeted resource. The resource's value is used to determine the next normal execution action.

  3. The resource is modified/checked concurrently by multiple processes. By using one of the processes, the attacker is able to modify the value just before it is consumed by a different process. A race condition occurs and is exploited by the Attacker to abuse the target host.

Attack Prerequisites

A resource is accessed/modified concurrently by multiple processes such that a race condition exists.

The attacker has the ability to modify the resource.

Typical Likelihood of Exploit

High

Methods of Attack
  • Time and State
  • Modification of Resources
Examples-Instances

Description

The Net Direct client for Linux before 6.0.5 in Nortel Application Switch 2424, VPN 3050 and 3070, and SSL VPN Module 1000 extracts and executes files with insecure permissions, which allows local users to exploit a race condition to replace a world-writable file in /tmp/NetClient and cause another user to execute arbitrary code when attempting to execute this client, as demonstrated by replacing /tmp/NetClient/client.

Related Vulnerability

CVE-2007-1057

Description

The following code illustrates a file that is accessed multiple times by name in a publicly accessible directory. A race condition exists between the accesses where an attacker can replace the file referenced by the name.

include <sys/types.h>
include <fcntl.h>
include <unistd.h>

define FILE    "/tmp/myfile"
define UID      100

void test(char *str)
{
        int fd;
        fd = creat(FILE, 0644);
        if(fd == -1)
                return;
        chown(FILE, UID, -1);      /* BAD */
        close(fd);
}

int main(int argc, char **argv)
{
        char *userstr;
        if(argc > 1) {
                userstr = argv[1];
                test(userstr);
        }
        return 0;
}

//Source : SAMATE.NIST.GOV : http://samate.nist.gov/SRD/view_testcase.php?login=Guest&;tID=1598

Attacker Skill or Knowledge Required

Medium/High

Probing Techniques

Vulnerability testing tool can be used to probe for race condition.

The attacker may also look for temporary file creation. The attacker may tries to replace them and take advantage of a race condition.

Solutions and Mitigations

Use safe libraries to access resources such as files.

Be aware that improper use of access function calls such as chown(), tempfile(), chmod(), etc. can cause a race condition.

Use synchronization to control the flow of execution.

Use static analysis tools to find race conditions.

Pay attention to concurrency problems related to the access of resources.

Attack Motivation-Consequences
  • Privilege Escalation
  • Data Modification
Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
368Context Switching Race ConditionSecondary
363Race Condition Enabling Link FollowingSecondary
366Race Condition within a ThreadSecondary
370Race Condition in Checking for Certificate RevocationSecondary
362Race ConditionSecondary
Purpose

Exploitation

CIA Impact
Confidentiality ImpactIntegrity ImpactAvailability Impact
LowHighMedium
Technical Context
Architectural ParadigmFrameworkPlatformLanguage
AllAllAllAll
References

G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004.

CWE – Race Conditions

Wikipedia, http://en.wikipedia.org/wiki/Race_condition

David Wheeler - Prevent race conditions - http://www-128.ibm.com/developerworks/linux/library/l-sprace.html

David Wheeler - Secure programming - http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/avoid-race.html

Source
Submission(s)
SubmitterOrganizationDateComment
Eric DalciCigital, Inc2007-01-25
Modification(s)
ModifierOrganizationDateComment
Sean BarnumCigital, Inc2007-03-07Review and revise
Richard StruseVOXEM, Inc2007-03-26Review and feedback leading to changes in Name, Description, Attack Flow and Attack Prerequisites
Sean BarnumCigital, Inc2007-04-13Modified pattern content according to review and feedback
 
Page Last Updated: April 18, 2008