Make FIFOs (named pipes)
Creates the fifos requested, in the order specified, using mode 0666 modified by the current
Creates the fifos requested, in the order specified, using mode 0666 modified by the current
Syntax
       mkfifo [-m mode] fifo_name ...
Options
  -m      Set the file permission bits of newly-created
          directories to mode. The mode is specified as in chmod.
          In symbolic mode strings, the `+' and `-' operators
          are interpreted relative to an assumed initial mode of `a=rw'
mkfifo requires write permission in the parent directory.
mkfifo exits 0 if successful, and >0 if an error occurred.
mkfifo exits 0 if successful, and >0 if an error occurred.
A "FIFO" is a special file type that permits independent processes to communicate. One process opens the FIFO file for writing, and another for reading, after which data can flow as with the usual anonymous pipe in shells or elsewhere.
| 
Attack Category | 
 | ||||||||||||||||||
| 
Vulnerability
   Category | 
 
 | ||||||||||||||||||
| 
Software Context | 
 
 | ||||||||||||||||||
| 
Location | 
 | ||||||||||||||||||
| 
Description | 
mkfifo
   makes a FIFO special file with name pathname. mode specifies the
   FIFO's permissions. It is modified by the process's umask in the
   usual way: the permissions of the created file are (mode &
   ~umask). A FIFO special file is similar to a pipe, except that it is created in a different way. Instead of being an anonymous communications channel, a FIFO special file is entered into the file system by calling mkfifo. 
Once
   you have created a FIFO special file in this way, any process can
   open it for reading or writing, in the same way as an ordinary
   file. However, it has to be open at both ends simultaneously
   before you can proceed to do any input or output operations on it.
   Opening a FIFO for reading normally blocks the file until some
   other process opens the same FIFO for writing, and vice versa. See
   fifo(4) for non-blocking handling of FIFO special files. 
mkfifo()
   is vulnerable to classic TOCTOU attacks. 
A call to mkfifo() should be
   flagged if the first argument (the file name) is used previously
   in a check. | ||||||||||||||||||
| 
APIs 
 | |||||||||||||||||||
| 
Method of Attack | 
The
   key issue with respect to TOCTOU vulnerabilities is that programs
   make assumptions about atomicity of actions. It is assumed that
   checking the state or identity of a targeted resource followed by
   an action on that resource is all one action. In reality, there is
   a period of time between the check and the use that allows either
   an attacker to intentionally or another interleaved process or
   thread to unintentionally change the state of the targeted
   resource and yield unexpected and undesired results. 
The
   mknod() call is a use-category call, which when preceded by a
   check-category call can be indicative of a TOCTOU vulnerability. 
A
   TOCTOU attack in regards to mkfifo() can occur, for example, when 
a. A
   check for the existence of a filename (check call) occurs 
b.
   mkfifo() is executed 
Between
   a and b, an attacker could, for example, create a hard link to the
   pathname, resulting ultimately in a "different" pipe
   being created than what was expected. | ||||||||||||||||||
| 
Exception Criteria | |||||||||||||||||||
| 
Solutions 
 | |||||||||||||||||||
| 
Signature Details | 
int
   mkfifo(const char *pathname, mode_t mode); | ||||||||||||||||||
| 
Examples of
   Incorrect Code 
 | |||||||||||||||||||
| 
Examples of
   Corrected Code 
 | |||||||||||||||||||
| 
Source References | 
 
 
 | ||||||||||||||||||
| 
Recommended Resource | |||||||||||||||||||
| 
Discriminant Set 
 | 
 
Tidak ada komentar:
Posting Komentar