Home > CAPEC List > CAPEC-26: Leveraging Race Conditions (Version 2.6)  

CAPEC-26: Leveraging Race Conditions

 
Leveraging Race Conditions
Definition in a New Window Definition in a New Window
Attack Pattern ID: 26
Abstraction: Standard
Status: Draft
Completeness: Complete
Presentation Filter:
+ 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
Explore
  1. The attacker explores to gauge what level of access he has.

Experiment
  1. 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.

Exploit
  1. 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 Severity

High

+ Typical Likelihood of Exploit

Likelihood: 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 Vulnerabilities

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;
}

[R.26.5]

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Medium

+ 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
ScopeTechnical ImpactNote
Confidentiality
Access_Control
Authorization
Gain privileges / assume identity
Integrity
Modify application data
+ Purposes
  • Exploitation
+ CIA Impact
Confidentiality Impact: LowIntegrity Impact: HighAvailability Impact: Medium
+ Technical Context
Architectural Paradigms
All
Frameworks
All
Platforms
All
Languages
All
+ References
[R.26.1] [REF-2] G. Hoglund and G. McGraw. "Exploiting Software: How to Break Code". Addison-Wesley. February 2004.
[R.26.2] [REF-3] "Common Weakness Enumeration (CWE)". CWE-362 - Race Conditions. Draft. The MITRE Corporation. 2007. <http://cwe.mitre.org/data/definitions/362.html>.
[R.26.3] [REF-6] "Wikipedia". Race condition. The Wikimedia Foundation, Inc. <http://en.wikipedia.org/wiki/Race_condition>.
[R.26.4] [REF-16] David Wheeler. "Secure programmer: Prevent race conditions". IBM developerWorks. IBM. <http://www.ibm.com/developerworks/linux/library/l-sprace/index.html>.
[R.26.5] [REF-41] Fortify Software. "SAMATE - Software Assurance Metrics And Tool Evaluation". Test Case ID 1598. National Institute of Standards and Technology (NIST). 2006-06-22. <http://samate.nist.gov/SRD/view_testcase.php?tID=1598>.
+ Content History
Submissions
SubmitterOrganizationDateSource
CAPEC Content TeamThe MITRE Corporation2014-06-23Internal_CAPEC_Team

More information is available — Please select a different filter.
Page Last Updated: December 04, 2014