alpine 3.9
crypto weakness #2

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:

dircproxy/src/dircproxy-RELEASE-1_2_0-BETA/crypt/main.c

Context:

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

 
  enc = crypt(pass, salt);
  printf("(DES) %s = %s\n", pass, enc);
}

/* Encrypt a password */
static void _encrypt_md5(const char *pass) 
{
   
     char salt[13], *enc;
     salt[0] = '$ ';
     salt[1] = '1';
     salt[2] = '$ ';
     _saltchar(&(salt[3]));
     _saltchar(&(salt[4]));
     _saltchar(&(salt[5]));
     _saltchar(&(salt[6]));
     _saltchar(&(salt[7]));
     _saltchar(&(salt[8]));
     _saltchar(&(salt[9]));
     _saltchar(&(salt[10]));
     salt[11] = '$ ';   
     salt[12] = 0;
   
     enc = crypt(pass, salt);
     printf("(MD5) %s = %s\n", pass, enc);
}



/* Pick a random salt character */
static void _saltchar(char *c) {
  static char *chars = "abcdefghijklmnopqrstuvwxyz"
                       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                       "01234567890";
  int ran;

  ran = (int)((double)(strlen(chars) - 1) * (rand() / (RAND_MAX + 1.0)));
  *c = chars[ran];
}

/* Print the usage instructions to stderr */
static int _print_usage(void) {
  fprintf(stderr, "%s: Try '%s --help' for more information.\n",
          progname, progname);

  return 0;
}

/* Print the version number to stderr */ 

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.