alpine 3.7
shell weakness #13

4

Weakness Breakdown


Definition:

A shell weakness occurs when a program enables an attacker to execute unexpected commands on the operating system.

Warning code(s):

This causes a new program to execute and is difficult to use safely.

File Name:

gdbm/src/gdbm-1.13/tests/g_open_ce.c

Context:

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

 
#ifndef O_CLOEXEC
# define O_CLOEXEC 0
#endif

int
main (int argc, char *argv[])
{
  GDBM_FILE d;
  char fdbuf[80];

  if (argc != 2)
    {
      fprintf (stderr, "usage: %s PATH-TO-FDOP\n", argv[0]);
      return 2;
    }
  if (!O_CLOEXEC)
    return 77;
  d = gdbm_open ("file.db", 0, GDBM_NEWDB|GDBM_CLOEXEC, 0600, NULL);
  if (!d)
    {
      fprintf (stderr, "gdbm_open: %s\n", gdbm_strerror (gdbm_errno));
      return 3;
    }
  execl (argv[1], "fdop",
	 ntos (gdbm_fdesc (d), fdbuf, sizeof (fdbuf)), NULL);
  return 127;
}
   

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.