A shell weakness occurs when a program enables an attacker to execute unexpected commands on the operating system.
This causes a new program to execute and is difficult to use safely.
gawk/src/gawk-4.1.4/pc/popen.c
The highlighted line of code below is the trigger point of this particular Alpine 3.6 shell weakness.
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>
#include <process.h>
#include <errno.h>
#include "popen.h"
#undef popen
#undef pclose
#undef system
#ifndef _NFILE
#define _NFILE 40
#endif
static struct {
char *command;
char *name;
char pmode[4];
} pipes[_NFILE];
/*
* For systems where system() and popen() do not follow SHELL:
* 1. Write command to temp file. Temp filename must have slashes
* compatible with SHELL (if set) or COMSPEC.
* 2. Convert slashes in SHELL (if present) to be compatible with COMSPEC.
* Currently, only MSC (running under DOS) and MINGW versions are managed.
*/
#if defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if 0
static int
unixshell(char *p)
{
static char *shell[] = {"sh", "bash", "csh", "tcsh", "sh32", "sh16", "ksh", NULL};
char **shellp = shell, *s, *q;
if (p == NULL) return (0);
s = p = strdup(p);
if ((q = strrchr(p, '\\')) != NULL)
p = q + 1;
if ((q = strrchr(p, '/')) != NULL)
p = q + 1;
if ((q = strchr(p, '.')) != NULL)
*q = '\0';