alpine 3.9
misc weakness #451

4

Weakness Breakdown


Definition:

The software specifies permissions for a security-critical resource in a way that allows the resource to be read or modified by unintended actors.

Warning code(s):

This function is obsolete and not portable. It was in SUSv2 but removed by POSIX.2. What it does exactly varies considerably between systems, particularly in where its prompt is displayed and where it gets its data.

File Name:

charybdis/src/charybdis-charybdis-3.5.6/tools/mkpasswd.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.9 misc weakness.

 			salt = make_sha512_salt(length);
	}

	if(flag & FLAG_PASS)
	{
		if(!plaintext)
		{
			fprintf(stderr, "Please enter a valid password\n");
			return 1;
		}

		hashed = rb_crypt(plaintext, salt);
	}
	else
	{
		plaintext = getpass("plaintext: ");
		hashed = rb_crypt(plaintext, salt);
		if (!hashed)
		{
			fprintf(stderr, "rb_crypt() failed\n");
			return 1;
		}
		hashed = strdup(hashed);

		plaintext = getpass("again: ");
		hashed2 = rb_crypt(plaintext, salt);
		if (!hashed2)
		{
			fprintf(stderr, "rb_crypt() failed\n");
			return 1;
		}

		if (strcmp(hashed, hashed2) != 0)
		{
			fprintf(stderr, "Passwords do not match\n");
			return 1;
		}
	}

	printf("%s\n", hashed);
	return 0;
}

static char *
make_des_salt()
{
	static char salt[3];
	generate_random_salt(salt, 2);
	salt[2] = '\0';
	return salt; 

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.