alpine 3.6
format weakness #92

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, and note that sprintf variations do not always 0-terminate.

File Name:

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

Context:

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

 }

char *
savecat(const char *s1, const char *s2)
{
	const char	*cp;
	char	*ns, *np;

	np = ns = salloc(strlen(s1) + strlen(s2) + 1);
	for (cp = s1; *cp; cp++)
		*np++ = *cp;
	for (cp = s2; *cp; cp++)
		*np++ = *cp;
	*np = '\0';
	return ns;
}

#include <stdarg.h>

#ifndef	HAVE_SNPRINTF
/*
 * Lazy vsprintf wrapper.
 */
int
snprintf(char *str, size_t size, const char *format, ...)
{
	va_list ap;
	int ret;

	va_start(ap, format);
	ret = vsprintf(str, format, ap);
	va_end(ap);
	return ret;
}
#endif	/* !HAVE_SNPRINTF */

/*
 * Announce a fatal error and die.
 */
void
panic(const char *format, ...)
{
	va_list ap;

	va_start(ap, format);
	fprintf(stderr, catgets(catd, CATSET, 1, "panic: "));
	vfprintf(stderr, format, ap);
	va_end(ap);
	fprintf(stderr, catgets(catd, CATSET, 2, "\n"));
	fflush(stderr); 

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.