centos 6
tmpfile weakness #41

4

Weakness Breakdown


Definition:

A temporary file weakness occurs when a temporary file that is created and used by a high-privilege process is accidentally shared with a low-privilege process, on account of it being temporary and generated after all security controls have been applied. This allows the low-privilege process to read data from the high-privilege process (information leakage), or worse, influence the high-privilege process by modifying the shared temporary file.

Warning code(s):

Temporary file race condition.

File Name:

glibc-2.12-2-gc4ccff1/misc/mktemp.c

Context:

The highlighted line of code below is the trigger point of this particular Centos 6 tmpfile weakness.

    Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#include <stdio.h>
#include <stdlib.h>

/* Generate a unique temporary file name from TEMPLATE.
   The last six characters of TEMPLATE must be "XXXXXX";
   they are replaced with a string that makes the filename unique.  */
char *
mktemp (template)
     char *template;
{
  if (__gen_tempname (template, 0, 0, __GT_NOCREATE) < 0)
    /* We return the null string if we can't find a unique file name.  */
    template[0] = '\0';

  return template;
}

link_warning (mktemp, "the use of 'mktemp' is dangerous, better use 'mkstemp'") 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.