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.
expect/src/expect5.45.4/pty_sgttyb.c
The highlighted line of code below is the trigger point of this particular Alpine 3.8 shell weakness.
static char *tty_type; /* ptr to char [pt] denoting
whether it is a pty or tty */
static char *tty_bank; /* ptr to char [p-z] denoting
which bank it is */
static char *tty_num; /* ptr to char [0-f] denoting
which number it is */
char *exp_pty_slave_name;
char *exp_pty_error;
static void
pty_stty(s,name)
char *s; /* args to stty */
char *name; /* name of pty */
{
#define MAX_ARGLIST 10240
char buf[MAX_ARGLIST]; /* overkill is easier */
RETSIGTYPE (*old)(); /* save old sigalarm handler */
#ifdef STTY_READS_STDOUT
sprintf(buf,"%s %s > %s",STTY_BIN,s,name);
#else
sprintf(buf,"%s %s < %s",STTY_BIN,s,name);
#endif
old = signal(SIGCHLD, SIG_DFL);
system(buf);
signal(SIGCHLD, old); /* restore signal handler */
}
int exp_dev_tty; /* file descriptor to /dev/tty or -1 if none */
static int knew_dev_tty;/* true if we had our hands on /dev/tty at any time */
#ifdef TIOCGWINSZ
static struct winsize winsize = {0, 0};
#endif
#if defined(TIOCGSIZE) && !defined(TIOCGWINSZ)
static struct ttysize winsize = {0, 0};
#endif
exp_tty exp_tty_original;
#define GET_TTYTYPE 0
#define SET_TTYTYPE 1
static void
ttytype(request,fd,ttycopy,ttyinit,s)
int request;
int fd;
/* following are used only if request == SET_TTYTYPE */
int ttycopy; /* if true, copy from /dev/tty */
int ttyinit; /* if true, initialize to sane state */
char *s; /* stty args */