Mitigate Baron SameEdit (CVE-2021-3156) vulnerability

sles 15.1
format weakness #6

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:

arptables-v0.0.4/arptables.c

Context:

The highlighted line of code below is the trigger point of this particular Sles 15.1 format weakness.

 	me->t = NULL;
	me->tflags = 0;
}

static void
print_num(u_int64_t number, unsigned int format)
{
	if (format & FMT_KILOMEGAGIGA) {
		if (number > 99999) {
			number = (number + 500) / 1000;
			if (number > 9999) {
				number = (number + 500) / 1000;
				if (number > 9999) {
					number = (number + 500) / 1000;
					if (number > 9999) {
						number = (number + 500) / 1000;
						printf(FMT("%4"PRIu64"T ","%"PRIu64"T "), number);
					}
					else printf(FMT("%4"PRIu64"G ","%"PRIu64"G "), number);
				}
				else printf(FMT("%4"PRIu64"M ","%"PRIu64"M "), number);
			} else
				printf(FMT("%4"PRIu64"K ","%"PRIu64"K "), number);
		} else
			printf(FMT("%5"PRIu64" ","%"PRIu64" "), number);
	} else
		printf(FMT("%8"PRIu64" ","%"PRIu64" "), number);
}


static void
print_header(unsigned int format, const char *chain, arptc_handle_t *handle)
{
	struct arpt_counters counters;
	const char *pol = arptc_get_policy(chain, &counters, handle);
	printf("Chain %s", chain);
	if (pol) {
		printf(" (policy %s", pol);
		if (!(format & FMT_NOCOUNTS)) {
			fputc(' ', stdout);
			print_num(counters.pcnt, (format|FMT_NOTABLE));
			fputs("packets, ", stdout);
			print_num(counters.bcnt, (format|FMT_NOTABLE));
			fputs("bytes", stdout);
		}
		printf(")\n");
	} else {
		unsigned int refs;
		if (!arptc_get_references(&refs, chain, handle))
			printf(" (ERROR obtaining refs)\n"); 

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.