alpine 3.6
format weakness #84

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/temp.c

Context:

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

 		tmpdir = "/tmp";
	}
	if (myname != NULL) {
		if (getuserid(myname) < 0) {
			printf(catgets(catd, CATSET, 198,
				"\"%s\" is not a user of this system\n"),
			    myname);
			exit(1);
		}
	} else {
		if ((cp = username()) == NULL) {
			myname = "nobody";
			if (rcvmode)
				exit(1);
		} else {
			myname = smalloc(strlen(cp) + 1);
			strcpy(myname, cp);
		}
	}
	if ((cp = getenv("HOME")) == NULL)
		cp = ".";
	homedir = smalloc(strlen(cp) + 1);
	strcpy(homedir, cp);
	if (debug || value("debug"))
		printf(catgets(catd, CATSET, 199,
			"user = %s, homedir = %s\n"), myname, homedir);
} 

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.