alpine 3.8
crypto weakness #7

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.

 				log_verbose(cd, _("Activating TCRYPT system encryption for partition %s.\n"),
					    part_path);
				dmd.data_device = part_device;
				dmd.u.crypt.offset = 0;
			}
			free(part_path);
		} else
			/*
			 * System encryption use the whole device mapping, there can
			 * be active partitions.
			 */
			device_check = DEV_SHARED;
	}

	r = device_block_adjust(cd, dmd.data_device, device_check,
				dmd.u.crypt.offset, &dmd.size, &dmd.flags);
	if (r) {
		device_free(part_device);
		return r;
	}

	/* Frome here, key size for every cipher must be the same */
	dmd.u.crypt.vk = crypt_alloc_volume_key(algs->cipher[0].key_size +
						algs->cipher[0].key_extra_size, NULL);
	if (!dmd.u.crypt.vk) {
		device_free(part_device);
		return -ENOMEM;
	}

	for (i = algs->chain_count; i > 0; i--) {
		if (i == 1) {
			dm_name[sizeof(dm_name)-1] = '\0';
			strncpy(dm_name, name, sizeof(dm_name)-1);
			dmd.flags = flags;
		} else {
			snprintf(dm_name, sizeof(dm_name), "%s_%d", name, i-1);
			dmd.flags = flags | CRYPT_ACTIVATE_PRIVATE;
		}

		snprintf(cipher, sizeof(cipher), "%s-%s",
			 algs->cipher[i-1].name, algs->mode);

		TCRYPT_copy_key(&algs->cipher[i-1], algs->mode,
				dmd.u.crypt.vk->key, hdr->d.keys);

		if (algs->chain_count != i) {
			snprintf(dm_dev_name, sizeof(dm_dev_name), "%s/%s_%d",
				 dm_get_dir(), name, i);
			r = device_alloc(&device, dm_dev_name);
			if (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.