Logo
-

Byte Open Security

(ByteOS Network)

Log In

Sign Up

ByteOS

Security
Vulnerability Details
Registries
Custom Views
Weaknesses
Attack Patterns
Filters & Tools
CAPEC-29:Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
Attack Pattern ID:29
Version:v3.9
Attack Pattern Name:Leveraging Time-of-Check and Time-of-Use (TOCTOU) Race Conditions
Abstraction:Standard
Status:Draft
Likelihood of Attack:High
Typical Severity:High
DetailsContent HistoryRelated WeaknessesReports
▼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.
▼Extended Description
▼Alternate Terms
▼Relationships
NatureTypeIDName
ChildOfM26Leveraging Race Conditions
ParentOfD27Leveraging Race Conditions via Symbolic Links
Nature: ChildOf
Type: Meta
ID: 26
Name: Leveraging Race Conditions
Nature: ParentOf
Type: Detailed
ID: 27
Name: Leveraging Race Conditions via Symbolic Links
▼Execution Flow
Explore
1.

The adversary explores to gauge what level of access they have.

The adversary explores to gauge what level of access they have.

Technique
Experiment
1.

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

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

Technique
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.

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.

Technique
▼Prerequisites
A resource is access/modified concurrently by multiple processes.
The adversary is able to modify resource.
A race condition exists while accessing a resource.
▼Skills Required
Medium

This attack can get sophisticated since the attack has to occur within a short interval of time.

▼Resources Required
▼Indicators
▼Consequences
ScopeLikelihoodImpactNote
IntegrityN/AModify DataN/A
ConfidentialityAccess ControlAuthorizationN/AGain PrivilegesN/A
ConfidentialityIntegrityAvailabilityN/AAlter Execution LogicN/A
ConfidentialityN/ARead DataN/A
AvailabilityN/AResource ConsumptionDenial of Service
Scope: Integrity
Likelihood: N/A
Impact: Modify Data
Note: N/A
Scope: Confidentiality, Access Control, Authorization
Likelihood: N/A
Impact: Gain Privileges
Note: N/A
Scope: Confidentiality, Integrity, Availability
Likelihood: N/A
Impact: Alter Execution Logic
Note: N/A
Scope: Confidentiality
Likelihood: N/A
Impact: Read Data
Note: N/A
Scope: Availability
Likelihood: N/A
Impact: Resource Consumption
Note: Denial of Service
▼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.
▼Example Instances
▼Related Weaknesses
IDName
CWE-362Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
CWE-366Race Condition within a Thread
CWE-367Time-of-check Time-of-use (TOCTOU) Race Condition
CWE-368Context Switching Race Condition
CWE-370Missing Check for Certificate Revocation after Initial Check
CWE-662Improper Synchronization
CWE-663Use of a Non-reentrant Function in a Concurrent Context
CWE-665Improper Initialization
CWE-691Insufficient Control Flow Management
ID: CWE-362
Name: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
ID: CWE-366
Name: Race Condition within a Thread
ID: CWE-367
Name: Time-of-check Time-of-use (TOCTOU) Race Condition
ID: CWE-368
Name: Context Switching Race Condition
ID: CWE-370
Name: Missing Check for Certificate Revocation after Initial Check
ID: CWE-662
Name: Improper Synchronization
ID: CWE-663
Name: Use of a Non-reentrant Function in a Concurrent Context
ID: CWE-665
Name: Improper Initialization
ID: CWE-691
Name: Insufficient Control Flow Management
▼Taxonomy Mappings
Taxonomy NameEntry IDEntry Name
▼Notes
▼References
Reference ID: REF-107
Title: SAMATE - Software Assurance Metrics And Tool Evaluation
Author: Fortify Software
Publication:
Publisher:National Institute of Standards and Technology (NIST)
Edition:
URL:http://samate.nist.gov/SRD/view_testcase.php?tID=1598
URL Date:
Day:22
Month:06
Year:2006
Reference ID: REF-131
Title: Building Secure Software
Author: J. Viega, G. McGraw
Publication:
Publisher:Addison-Wesley
Edition:
URL:
URL Date:
Day:N/A
Month:N/A
Year:2002
Details not found