alpine 3.8
crypto weakness #16

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:

cryptsetup1/src/cryptsetup-1.7.5/lib/tcrypt/tcrypt.c

Context:

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

 	if (r < 0)
		return r;

	r = dm_query_device(cd, dm_name, DM_ACTIVE_DEVICE |
					  DM_ACTIVE_UUID |
					  DM_ACTIVE_CRYPT_CIPHER |
					  DM_ACTIVE_CRYPT_KEYSIZE, &dmd);
	if (r > 0)
		r = 0;
	if (!r && !strncmp(dmd.uuid, base_uuid, strlen(base_uuid))) {
		if ((c = strchr(dmd.u.crypt.cipher, '-')))
			*c = '\0';
		strcat(cipher, "-");
		strncat(cipher, dmd.u.crypt.cipher, MAX_CIPHER_LEN);
		*key_size += dmd.u.crypt.vk->keylength;
		*data_offset = dmd.u.crypt.offset * SECTOR_SIZE;
		device_free(*device);
		*device = dmd.data_device;
	} else {
		device_free(dmd.data_device);
		r = -ENODEV;
	}

	free(CONST_CAST(void*)dmd.uuid);
	free(CONST_CAST(void*)dmd.u.crypt.cipher);
	crypt_free_volume_key(dmd.u.crypt.vk);
	return r;
}

int TCRYPT_init_by_name(struct crypt_device *cd, const char *name,
			const struct crypt_dm_active_device *dmd,
			struct device **device,
			struct crypt_params_tcrypt *tcrypt_params,
			struct tcrypt_phdr *tcrypt_hdr)
{
	struct tcrypt_algs *algs;
	char cipher[MAX_CIPHER_LEN * 4], mode[MAX_CIPHER_LEN+1], *tmp;
	size_t key_size;
	int r;

	memset(tcrypt_params, 0, sizeof(*tcrypt_params));
	memset(tcrypt_hdr, 0, sizeof(*tcrypt_hdr));
	tcrypt_hdr->d.sector_size = SECTOR_SIZE;
	tcrypt_hdr->d.mk_offset = dmd->u.crypt.offset * SECTOR_SIZE;

	strncpy(cipher, dmd->u.crypt.cipher, MAX_CIPHER_LEN);
	tmp = strchr(cipher, '-');
	if (!tmp)
		return -EINVAL;
	*tmp = '\0'; 

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.