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.
Ensure that umask is given most restrictive possible setting.
The highlighted line of code below is the trigger point of this particular Alpine 3.6 access weakness.
sigaction(SIGALRM, &act, NULL); alarm(ALARMC); fcntl(lockdes, F_SETLKW, &lock); alarm(0); if ((jobno = nextjob()) == EOF) perr("Cannot generate job number"); (void)snprintf(ppos, sizeof(atfile) - (ppos - atfile), "%c%5lx%8lx", queue, jobno, (unsigned long) (runtimer / 60)); for (ap = ppos; *ap != '\0'; ap++) if (*ap == ' ') *ap = '0'; if (stat(atfile, &statbuf) != 0) if (errno != ENOENT) perr("Cannot access " ATJOB_DIR); /* Create the file. The x bit is only going to be set after it has * been completely written out, to make sure it is not executed in the * meantime. To make sure they do not get deleted, turn off their r * bit. Yes, this is a kluge. */ cmask = umask(S_IRUSR | S_IWUSR | S_IXUSR); seteuid(real_uid); if ((fd = open(atfile, O_CREAT | O_EXCL | O_TRUNC | O_WRONLY, S_IRUSR)) == -1) perr("Cannot create atjob file %.500s", atfile); seteuid(effective_uid); if ((fd2 = dup(fd)) < 0) perr("Error in dup() of job file"); /* if (fchown(fd2, real_uid, real_gid) != 0) perr("Cannot give away file"); */ PRIV_END /* We no longer need suid root; now we just need to be able to write * to the directory, if necessary. */ REDUCE_PRIV(daemon_uid, daemon_gid) /* We've successfully created the file; let's set the flag so it * gets removed in case of an interrupt or error. */ fcreated = 1;