alpine 3.7
crypto weakness #282

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:

mkinitfs/src/mkinitfs-3.2.0/nlplug-findfs.c

Context:

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

 	return 0;
}

static void notify_main(struct ueventconf *conf)
{
	uint64_t one = 1;
	write(conf->efd, &one, sizeof one);
}

static void *cryptsetup_thread(void *data)
{
	struct ueventconf *c = (struct ueventconf *)data;
	const char *data_devnode, *header_devnode;
	struct crypt_params_luks1 param_struct;
	struct crypt_params_luks1 *params = NULL;
	struct crypt_device *cd;
	int r, passwd_tries = 5;

	data_devnode = header_devnode = c->crypt.data.devnode;

	if(c->crypt.header.devnode[0] != '\0') {
		params = &param_struct;
		params->hash = NULL; /* No way of finding this */
		params->data_alignment = c->crypt.payload_offset; /* Memset did set that to 0, so default is 0 */
		params->data_device = c->crypt.data.devnode;
		header_devnode = c->crypt.header.devnode;
	}

	r = crypt_init(&cd, header_devnode);
	if (r < 0) {
		warnx("crypt_init(%s)", header_devnode);
		goto notify_out;
	}

	r = crypt_load(cd, CRYPT_LUKS1, params);
	if (r < 0) {
		warnx("crypt_load(%s)", data_devnode);
		goto free_out;
	}

	r = crypt_set_data_device(cd, data_devnode);
	if (r < 0) {
		warnx("crypt_set_data_device(%s)", data_devnode);
		goto free_out;
	}

	while (passwd_tries > 0) {
		char pass[1024];

		printf("Enter passphrase for %s: ", c->crypt.data.devnode); 

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.