alpine 3.9
crypto weakness #2


Weakness Breakdown


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:



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] = '$ ';
     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"
  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.