alpine 3.6
format weakness #74

4

Weakness Breakdown


Definition:

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:

heirloom-mailx/src/mailx-12.4/sendout.c

Context:

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

 }

/*
 * Start the Mail Transfer Agent
 * mailing to namelist and stdin redirected to input.
 */
static enum okay
start_mta(struct name *to, struct name *mailargs, FILE *input,
		struct header *hp)
{
	char **args = NULL, **t;
	pid_t pid;
	sigset_t nset;
	char *cp, *smtp;
	char	*user = NULL, *password = NULL, *skinned = NULL;
	enum okay	ok = STOP;
#ifdef	HAVE_SOCKETS
	struct termios	otio;
	int	reset_tio;
#endif	/* HAVE_SOCKETS */

	if ((smtp = value("smtp")) == NULL) {
		args = unpack(cat(mailargs, to));
		if (debug || value("debug")) {
			printf(catgets(catd, CATSET, 181,
					"Sendmail arguments:"));
			for (t = args; *t != NULL; t++)
				printf(" \"%s\"", *t);
			printf("\n");
			return OKAY;
		}
	}
#ifdef	HAVE_SOCKETS
	if (smtp != NULL) {
		skinned = skin(myorigin(hp));
		if ((user = smtp_auth_var("-user", skinned)) != NULL &&
				(password = smtp_auth_var("-password",
					skinned)) == NULL)
			password = getpassword(&otio, &reset_tio, NULL);
	}
#endif	/* HAVE_SOCKETS */
	/*
	 * Fork, set up the temporary mail file as standard
	 * input for "mail", and exec with the user list we generated
	 * far above.
	 */
	if ((pid = fork()) == -1) {
		perror("fork");
		savedeadletter(input);
		senderr++; 

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.