alpine 3.6
tmpfile weakness #71

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:

xrdb/src/xrdb-1.1.0/xrdb.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 tmpfile weakness.

     if (!(dpy = XOpenDisplay (displayname)))
	fatal("%s: Can't open display '%s'\n", ProgramName,
		 XDisplayName (displayname));

    if (whichResources == RALL && ScreenCount(dpy) == 1)
	whichResources = RGLOBAL;

#ifdef PATHETICCPP
    if (cpp_program &&
	(oper == OPLOAD || oper == OPMERGE || oper == OPOVERRIDE)) {
	need_real_defines = True;
#ifdef WIN32
	strcpy(tmpname2, "xrdbD_XXXXXX");
	strcpy(tmpname3, "\\temp\\xrdbD_XXXXXX");
#else
#ifdef __UNIXOS2__
	{ char *tmpdir=getenv("TMP");
	  if (!tmpdir) tmpdir="/";
	  sprintf(tmpname2, "%s/xrdbD_XXXXXX",tmpdir);
	}
#else
	strcpy(tmpname2, "/tmp/xrdbD_XXXXXX");
#endif
#endif
	(void) mktemp(tmpname2);
    }
#endif

    if (!filename &&
#ifdef PATHETICCPP
	need_real_defines
#else
	(oper == OPLOAD || oper == OPMERGE || oper == OPOVERRIDE) &&
	(whichResources == RALL || whichResources == RSCREENS)
#endif
	) {
	char inputbuf[1024];
#ifdef WIN32
	strcpy(tmpname, "\\temp\\xrdb_XXXXXX");
#else
#ifdef __UNIXOS2__
	{ char *tmpdir=getenv("TMP");
	  if (!tmpdir) tmpdir="/";
	  sprintf(tmpname, "%s/xrdb_XXXXXX",tmpdir);
	}
#else
	strcpy(tmpname, "/tmp/xrdb_XXXXXX");
#endif
#endif
#ifndef HAVE_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.