alpine 3.8
crypto weakness #8

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.

 	}

	/* 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)
				break;
			dmd.data_device = device;
			dmd.u.crypt.offset = 0;
		}

		log_dbg("Trying to activate TCRYPT device %s using cipher %s.",
			dm_name, dmd.u.crypt.cipher);
		r = dm_create_device(cd, dm_name, CRYPT_TCRYPT, &dmd, 0);

		device_free(device);
		device = NULL;

		if (r)
			break;
	}

	if (r < 0 && !(dm_flags() & req_flags)) {
		log_err(cd, _("Kernel doesn't support TCRYPT compatible mapping.\n"));
		r = -ENOTSUP; 

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.