alpine 3.6
access weakness #84

1

Weakness Breakdown


Definition:

An access weakness occurs when software does not properly implement permissions that could have unintended consequences if exploited by malicious actors. An example of this weakness is when a default username and password are set by the developer but do not get changed by the system administrator.

Warning code(s):

Ensure that umask is given most restrictive possible setting.

File Name:

lua-lunix/src/lunix-tag-20150923/src/unix.c

Context:

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

 
		if ((error = u_pipe(U->ts.fd, O_NONBLOCK|U_CLOEXEC)))
			return error;

		U->ts.pid = getpid();
	} else {
		mode_t mask;

		while (read(U->ts.fd[0], &mask, sizeof mask) > 0)
			;;
	}

	return 0;
} /* ts_reset() */

static mode_t unixL_getumask(lua_State *L) {
	unixL_State *U = unixL_getstate(L);
	pid_t pid;
	mode_t mask;
	int error, status;
	ssize_t n;

#if 0
	if (ts_nthreads() == 1) {
		mask = umask(0);
		umask(mask);

		return mask;
	}
#endif

	if ((error = ts_reset(U)))
		return luaL_error(L, "getumask: %s", unixL_strerror(L, error));

	switch ((pid = fork())) {
	case -1:
		return luaL_error(L, "getumask: %s", unixL_strerror(L, errno));
	case 0:
		mask = umask(0777);

		if (sizeof mask != write(U->ts.fd[1], &mask, sizeof mask))
			_Exit(1);

		_Exit(0);

		break;
	default:
		while (-1 == waitpid(pid, &status, 0)) {
			if (errno == ECHILD)
				break; /* somebody else caught it */ 

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.