alpine 3.8
crypto weakness #10

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.

 			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;
	}

	device_free(part_device);
	crypt_free_volume_key(dmd.u.crypt.vk);
	return r;
}

static int TCRYPT_remove_one(struct crypt_device *cd, const char *name,
		      const char *base_uuid, int index)
{
	struct crypt_dm_active_device dmd = {};
	char dm_name[PATH_MAX];
	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.