alpine 3.9
crypto weakness #12

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.

 	return ret;
}

static char * _hash_des(char const * password, char const * salt)
{
	char * ret;
	const char characters[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
		"abcdefghijklmnopqrstuvwxyz";
	char * p = NULL;

	if(salt != NULL)
	{
		if(salt[0] == '$ ' || salt[0] == '_')
		{
			errno = EINVAL;
			_error("des", 1);
			return NULL;
		}
	}
	/* FIXME also implement the mode with '_' as first character */
	else if((p = _makepasswd_password(characters, 2, 2)) == NULL)
		return NULL;
	else
		salt = p;
	ret = crypt(password, salt);
	free(p);
	if(ret == NULL)
	{
		_error("crypt", 1);
		return NULL;
	}
	if((ret = strdup(ret)) == NULL)
		_error("malloc", 1);
	return ret;
}

static char * _hash_md5(char const * password)
{
	char * ret;
	unsigned char digest[16];
	unsigned short i;
	unsigned char j;
	MD5_CTX c;

	if((ret = malloc(33)) == NULL)
	{
		_error("malloc", 1);
		return NULL;
	}
	/* call md5 implementation from RSA Data Security, Inc. */ 

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.