alpine 3.6
format weakness #86

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/v7.local.c

Context:

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

 /*
 * Get rid of the queued mail.
 */
void 
demail(void)
{

	if (value("keep") != NULL || rm(mailname) < 0)
		close(creat(mailname, 0600));
}

/*
 * Discover user login name.
 */
char *
username(void)
{
	char *np;
	uid_t uid;

	if ((np = getenv("USER")) != NULL)
		return np;
	if ((np = getname(uid = getuid())) != NULL)
		return np;
	printf(catgets(catd, CATSET, 201,
		"Cannot associate a name with uid %d\n"), (int)uid);
	return NULL;
} 

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.