Home     Blog

Race Condition

A race condition occurs when multiple processes access and manipulate the same data concurrently, and the outcome of the execution depends on the particular order in which the access takes place.

A race condition is of interest to a hacker when the race condition can be utilized to gain privileged system access.

Consider the following code snippet which illustrates a race condition:

if(access("/tmp/datafile",R_OK)==0){
	fd=open("/tmp/datafile
 process(fd);
 close(fd);

This code creates the temporary file /tmp/datafile and then opens it.

The potential race condition occurs between the call to access() and the call to open(). If an attacker can replace the contents of /tmp/datafile between the access() and open() functions, he can manipulate the actions of the program which uses that datafile. This is the race.

race condition Race Condition

It can be difficult to exploit a race condition, because you may have to "run the race" many times before you "win." You may have to run the vulnerable program and the vulnerability testing tool thousands of times before you get the expolit code to execute after the vulnerability opens and before the vulnerability closes. It is sometimes possible to give the attack an extra edge by using `nice` to lower the priority of the legitimate suid program.

Improper use of the function calls access(), chown(), chgrp(), chmod(), mktemp(), tempnam(), tmpfile(), and tmpnam() are the most common causes of race conditions.

VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
Follow Will.Spencer on

Comments (3)

 

  1. Nametso Lewaneka says:

    how do one create two ascending and two descending ships as different theads? First create the canal lock where the ships passes.

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
  2. Rapelang says:

    One way to prevent a race condition is never to run the producer and consumer concurrently. Explain why this is not the best solution?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
  3. gakumba geoffrey says:

    apologise me,this is not a comment but is a problem.
    can we have some programming code in java,c,c++ or any other programming languange to  help us with a huge understanding please?

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Related Posts

  • How to Find Security Vulnerabilities in Source Code

    The original, and still the best, method for finding security vulnerabilities in source code is to read and understand the source code. Source code security vulnerabilities will vary between languages and platforms. Items to look for in C code include: Potential vulnerability Function calls to examine for vulnerabilities Buffer overflows gets(), scanf(), sprintf(), strcat(), strcpy() [...]...


  • Security Problems with SUID Scripts and Programs

    There are many methods which have been used to gain root priviledges from a Unix SUID (Set User ID) script or program. It is the task of the programmer of the SUID script or program to prevent the hacker from gaining root access. Here are some methods which hackers utilize and which programmers should prevent: [...]...


  • 0-day

    0 Day, or Zero Day, refers to a type of malware which attacks a computer or application by exploiting vulnerabilities that the developer of that application does not yet know about. In traditional sense, 0 Day refers to the first day that a developer notices a vulnerability in an application he/she created and begins creating a [...]...


  • Random Number Vulnerability

    Computers are deterministic and are therefore predictable. Computers cannot, in and of themselves, generate truly random numbers. In the absence of outside input, computers can only create pseudo-random numbers.  In the words of John Von Neumann, “Anyone attempting to produce random numbers by purely arithmetic means is, of course, in a state of sin.” A [...]...


  • Format String Vulnerability

    To understand what a format string vulnerability is, you first need to know what a format string is. A format string is a way of telling the C compiler how it should format numbers when it prints them. Format Strings in C In the C programming language there are a number of functions which accept [...]...