COMMON ATTACK PATTERN ENUMERATION AND CLASSIFICATIONMITRE canlı kaydı

CAPEC-29

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

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.

Soyutlama

Standard

Tipik ciddiyet

High

Saldırı ihtimali

High

Saldırıyı anla

Bu saldırı kalıbı nedir?

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.

Uygulama akışı

Saldırı adım adım nasıl ilerler?

1

Explore

Attack step

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

Experiment

Attack step

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

Exploit

Attack step

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.

Gereksinimler

Saldırının gerçekleşmesi için ne gerekir?

Ön koşullar

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

Gerekli beceri

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

Gerekli kaynak

MITRE kaydında belirtilmemiş.

Etki

Başarılı saldırı neye yol açar?

Modify Data

Etkilenen alanlar: Integrity

Gain Privileges

Etkilenen alanlar: Confidentiality, Access Control, Authorization

Alter Execution Logic

Etkilenen alanlar: Confidentiality, Integrity, Availability

Read Data

Etkilenen alanlar: Confidentiality

Resource Consumption

Etkilenen alanlar: Availability

Savunma

Nasıl önlenir ve etkisi azaltılır?

1
Use safe libraries to access resources such as files.
2
Be aware that improper use of access function calls such as chown(), tempfile(), chmod(), etc. can cause a race condition.
3
Use synchronization to control the flow of execution.
4
Use static analysis tools to find race conditions.
5
Pay attention to concurrency problems related to the access of resources.

Gerçek dünya

MITRE örnek olayları

Örnek olay 1Detay
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
Örnek olay 2Detay
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 <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; } [ REF-107 ]