alpine 3.9
crypto weakness #17

4

Weakness Breakdown


Definition:

This weakness involves creating non-standard or non-tested algorithms, using weak algorithms or applying cryptographic algorithms incorrectly. Algorithms that were once considered safe are commonly later found to be unsafe, as the algorithms were broken.

Warning code(s):

The crypt functions use a poor one-way hashing algorithm; since they only accept passwords of 8 characters or fewer and only a two-byte salt, they are excessively vulnerable to dictionary attacks given today's faster computing equipment.

File Name:

makepasswd/src/makepasswd-0.5.3/src/makepasswd.c

Context:

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

 	{
		errno = EINVAL;
		_error("blowfish", 1);
		return NULL;
	}
	if(salt == NULL)
	{
		if((p = _makepasswd_password(characters, 16, 16)) == NULL)
			return NULL;
		salt = p;
	}
	if((salt64 = _hash_base64(salt)) == NULL)
	{
		free(p);
		return NULL;
	}
	len = sizeof(prefix) + 3 + strlen(salt64);
	if((s = malloc(len)) == NULL)
	{
		_error("malloc", 1);
		free(p);
		return NULL;
	}
	snprintf(s, len, "%s%02u%c%s", prefix, iterations, '$ ', salt64);
	ret = crypt(password, s);
	free(salt64);
	free(p);
	free(s);
	if(ret == NULL)
		_error("crypt", 1);
	else if(strcmp(ret, ":") == 0)
	{
		errno = EINVAL;
		_error("blowfish", 1);
		ret = NULL;
	}
	else if(strncmp(ret, prefix, sizeof(prefix) - 1) != 0)
	{
		errno = ENOTSUP;
		_error("blowfish", 1);
		ret = NULL;
	}
	else if((ret = strdup(ret)) == NULL)
		_error("malloc", 1);
	return ret;
}

static char * _hash_des(char const * password, char const * salt)
{
	char * ret; 

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.