Dark Mode

Settings

Capec-29 Detail

Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions

Standard Software Likelihood: High Typical Severity: High

Parents: 26

Children: 27

Threats: T79 T287 T337 T391 T406

Description

This attack targets a race condition occurring between the time of check (state) for a resource and the time of use of a resource. A typical example is file access. The adversary can leverage a file access race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary could replace or modify the file, causing the application to behave unexpectedly.

Not present

External ID Source Link Description
CAPEC-29 capec https://capec.mitre.org/data/definitions/29.html
CWE-367 cwe http://cwe.mitre.org/data/definitions/367.html
CWE-368 cwe http://cwe.mitre.org/data/definitions/368.html
CWE-366 cwe http://cwe.mitre.org/data/definitions/366.html
CWE-370 cwe http://cwe.mitre.org/data/definitions/370.html
CWE-362 cwe http://cwe.mitre.org/data/definitions/362.html
CWE-662 cwe http://cwe.mitre.org/data/definitions/662.html
CWE-691 cwe http://cwe.mitre.org/data/definitions/691.html
CWE-663 cwe http://cwe.mitre.org/data/definitions/663.html
CWE-665 cwe http://cwe.mitre.org/data/definitions/665.html
REF-131 reference_from_CAPEC J. Viega, G. McGraw, Building Secure Software, 2002, Addison-Wesley
REF-107 reference_from_CAPEC http://samate.nist.gov/SRD/view_testcase.php?tID=1598 Fortify Software, SAMATE - Software Assurance Metrics And Tool Evaluation, 2006--06---22, National Institute of Standards and Technology (NIST)
Explore
  1. The adversary explores to gauge what level of access they have.

Experiment
  1. The adversary confirms access to a resource on the target host. The adversary confirms ability to modify the targeted resource.

Exploit
  1. The adversary decides to leverage the race condition by "running the race", meaning that they would modify the resource between the first time the target program accesses the file and the time the target program uses the file. During that period of time, the adversary can replace the resource and cause an escalation of privilege.

  1. A resource is access/modified concurrently by multiple processes.
  2. The adversary is able to modify resource.
  3. A race condition exists while accessing a resource.

Not present

Medium
This attack can get sophisticated since the attack has to occur within a short interval of time.
Integrity Availability Authorization Access Control Confidentiality
Modify Data Alter Execution Logic Gain Privileges Gain Privileges Gain Privileges
Alter Execution Logic Resource Consumption (Denial of Service) Alter Execution Logic
Read Data
  1. 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. See also: CVE-2007-1057
  2. 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 adversary can replace the file referenced by the name. include include include 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; } [REF-107]