alpine 3.8
format weakness #28


Weakness Breakdown


A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

If format strings can be influenced by an attacker, they can be exploited.

File Name:



The highlighted line of code below is the trigger point of this particular Alpine 3.8 format weakness.


/* Print "name=value\n" to stdout for a limb, nail doesn't have to be zero. */
mp_limb_trace (const char *name, mp_limb_t n)
#if GMP_NAIL_BITS != 0
  mp_limb_t  a[2];
  a[0] = n & GMP_NUMB_MASK;
  a[1] = n >> GMP_NUMB_BITS;
  mpn_trace (name, a, (mp_size_t) 2);
  mpn_trace (name, &n, (mp_size_t) 1);

/* Print "namenum=value\n" to stdout for an mpn style ptr,size.
   "name" should have a "%d" to get the number.  */
mpn_tracen (const char *name, int num, mp_srcptr ptr, mp_size_t size)
  if (name != NULL && name[0] != '\0')
      printf (name, num);
      putchar ('=');
  mpn_trace (NULL, ptr, size);

/* Print "namenum=value\n" to stdout for an array of mpn style ptr,size.

   "a" is an array of pointers, each a[i] is a pointer to "size" many limbs.
   The formal parameter isn't mp_srcptr because that causes compiler
   warnings, but the values aren't modified.

   "name" should have a printf style "%d" to get the array index.  */

mpn_tracea (const char *name, const mp_ptr *a, int count, mp_size_t size)
  int i;
  for (i = 0; i < count; i++)
    mpn_tracen (name, i, a[i], size);

/* Print "value\n" to a file for an mpz_t value.  Any previous contents of
   the file are overwritten, so you need different file names each time this 

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.