alpine 3.6
format weakness #23


Weakness Breakdown


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:



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

 			new = gexpand(new, gh, metoo, np->n_type);
			new = put(new, np);
		np = cp;

 * Recursively expand a group name.  We limit the expansion to some
 * fixed level to keep things from going haywire.
 * Direct recursion is not expanded for convenience.

static struct name *
gexpand(struct name *nlist, struct grouphead *gh, int metoo, int ntype)
	struct group *gp;
	struct grouphead *ngh;
	struct name *np;
	static int depth;
	char *cp;

	if (depth > MAXEXP) {
		printf(catgets(catd, CATSET, 150,
			"Expanding alias to depth larger than %d\n"), MAXEXP);
	for (gp = gh->g_list; gp != NULL; gp = gp->ge_link) {
		cp = gp->ge_name;
		if (*cp == '\\')
			goto quote;
		if (strcmp(cp, gh->g_name) == 0)
			goto quote;
		if ((ngh = findgroup(cp)) != NULL) {
			nlist = gexpand(nlist, ngh, metoo, ntype);
		np = nalloc(cp, ntype|GFULL);
		 * At this point should allow to expand
		 * to self if only person in group
		if (gp == gh->g_list && gp->ge_link == NULL)
			goto skip;
		if (!metoo && same_name(cp, myname))
			np->n_type |= GDEL;

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.