alpine 3.6
crypto weakness #52

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:

syslinux/src/syslinux-6.04-pre1/com32/cmenu/libmenu/passwords.c

Context:

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

 #include "passwords.h"
#include "des.h"
#include "string.h"
#include <stdlib.h>
#include <stdio.h>
#include "tui.h"

#define MAX_LINE 512
// Max line length in a pwdfile
p_pwdentry userdb[MAX_USERS];	// Array of pointers
int numusers;			// Actual number of users

// returns true or false, i.e. 1 or 0
char authenticate_user(const char *username, const char *pwd)
{
    char salt[12];
    int i;

    for (i = 0; i < numusers; i++) {
	if (userdb[i] == NULL)
	    continue;
	if (strcmp(username, userdb[i]->username) == 0) {
	    strcpy(salt, userdb[i]->pwdhash);
	    salt[2] = '\0';
	    if (strcmp(userdb[i]->pwdhash, crypt(pwd, salt)) == 0)
		return 1;
	}
    }
    return 0;
}

// Does user USERNAME  have permission PERM
char isallowed(const char *username, const char *perm)
{
    int i;
    char *dperm;
    char *tmp;

    // If no users, then everybody is allowed to do everything
    if (numusers == 0)
	return 1;
    if (strcmp(username, GUEST_USER) == 0)
	return 0;
    dperm = (char *)malloc(strlen(perm) + 3);
    strcpy(dperm + 1, perm);
    dperm[0] = ':';
    dperm[strlen(perm) + 1] = ':';
    dperm[strlen(perm) + 2] = 0;
    // Now dperm = ":perm:"
    for (i = 0; i < numusers; i++) { 

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.