alpine 3.8
crypto weakness #13

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.

 			      size_t *key_size, char *cipher,
			      uint64_t *data_offset, struct device **device)
{
	struct crypt_dm_active_device dmd = {};
	char dm_name[PATH_MAX], *c;
	int r;

	if (snprintf(dm_name, sizeof(dm_name), "%s_%d", name, index) < 0)
		return -ENOMEM;

	r = dm_status_device(cd, dm_name);
	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; 

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.