alpine 3.6
access weakness #324


Weakness Breakdown


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:



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

 			log_error("A non-block device file at '%s' "
				  "is already present", path);
			return 0;

		/* If right inode already exists we don't touch uid etc. */
		if (info.st_rdev == dev)
			return 1;

		if (unlink(path) < 0) {
			log_error("Unable to unlink device node for '%s'",
			return 0;
	} else if (_warn_if_op_needed(warn_if_udev_failed))
		log_warn("%s not set up by udev: Falling back to direct "
			 "node creation.", path);

	(void) dm_prepare_selinux_context(path, S_IFBLK);
	old_mask = umask(0);

	/* The node may already have been created by udev. So ignore EEXIST. */
	if (mknod(path, S_IFBLK | mode, dev) < 0 && errno != EEXIST) {
		log_error("%s: mknod for %s failed: %s", path, dev_name, strerror(errno));
		(void) dm_prepare_selinux_context(NULL, 0);
		return 0;
	(void) dm_prepare_selinux_context(NULL, 0);

	if (chown(path, uid, gid) < 0) {
		log_sys_error("chown", path);
		return 0;

	log_debug_activation("Created %s", path);

	return 1;

static int _rm_dev_node(const char *dev_name, int warn_if_udev_failed)
	char path[PATH_MAX];
	struct stat info;

	if (!_build_dev_path(path, sizeof(path), dev_name))
	if (lstat(path, &info) < 0)
		return 1; 

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.