alpine 3.6
format weakness #4

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:

arping/src/arping-2.18/src/arping.c

Context:

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

                 }
        }
#endif
        if ((rc = pcap_activate(pcap))) {
                if (timestamp_type) {
                        snprintf(errbuf, PCAP_ERRBUF_SIZE, "pcap_activate(tstype=\"%s\"): %s. Try without setting timestamp type.", timestamp_type, pcap_statustostr(rc));
                } else {
                        snprintf(errbuf, PCAP_ERRBUF_SIZE, "pcap_activate(): %s", pcap_statustostr(rc));
                }
                goto err;
        }
#ifdef HAVE_PCAP_LIST_TSTAMP_TYPES
        // List timestamp types after activating, since we don't want to list
        // them if activating failed.
        if (verbose > 1) {
                int *ts;
                int count;
                count = pcap_list_tstamp_types(pcap, &ts);
                if (count == PCAP_ERROR) {
                        fprintf(stderr, "arping: pcap_list_tstamp_types() failed\n");
                } else {
                        int c;
                        const char* fmt = "  %-18s %s\n";
                        fprintf(stderr, "Timestamp types:\n");
                        fprintf(stderr, fmt, "Name", "Description");
                        for (c = 0; c < count; c++) {
                                fprintf(stderr, fmt, pcap_tstamp_type_val_to_name(ts[c]),
                                        pcap_tstamp_type_val_to_description(ts[c]));
                        }
                        pcap_free_tstamp_types(ts);
                }
        }
#endif
        return pcap;
err:
        if (pcap) {
                pcap_close(pcap);
        }
        return NULL;
#else
        return pcap_open_live(device, snaplen, promisc, to_ms, errbuf);
#endif
}

/**
 * Some stupid OSs (Solaris) think it's a good idea to put network
 * devices in /dev and then play musical chairs with them.
 *
 * Since libpcap doesn't seem to have a workaround for that, here's arpings
 * workaround. 

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.