Today we’ll learn how to spot and fix a race condition in Unix Systems. It is a frequent source of vulnerabilities and that can occur also in other areas such as Web Applications.

We’ll first define what is a race condition, how to exploit it and eventually what could we do to fix/mitigate it.

1. What is a race condition ?

A race condition occurs when multiple processes/threads access and manipulate the same data concurrently and their timing or the ordering of events affects the program’s outcome.

Race conditions can happen in different ways :

  • If a privileged program has a race-condition vulnerability, attackers can run a parallel process to “race” against the privileged program and manipulate the same data as the legitimate program. This is the example we’ll be dealing with in this article.
  • Thread context switching: 2 threads access the same data at the same time, interfering with each other. In this situation, the outcome may depend on which order the threads accessed the shared data. Here you have an example:

But all the different race conditions have these properties in common :

  • Concurrency Property: There must be at least 2 flows running simultaneously
  • Shared Object Property: A shared race object must be accessed by both of the concurrent flows
  • Change State Property: At least one of the flow must alter the state of the object

#c-programming-language #unix #cybersecurity

Race Condition Vulnerability in Unix Systems
1.10 GEEK