fedora 24
format weakness #5

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:

at-3.1.18/panic.c

Context:

The highlighted line of code below is the trigger point of this particular Fedora 24 format weakness.

 void
panic(char *a)
{
/* Something fatal has happened, print error message and exit.
 */
    fprintf(stderr, "%s: %s\n", namep, a);
    if (fcreated) {
	setregid(real_gid, effective_gid);
	unlink(atfile);
	setregid(effective_gid, real_gid);
    }

    exit(EXIT_FAILURE);
}

void
perr(const char *fmt,...)
{
/* Some operating system error; print error message and exit.
 */
    char buf[1024];
    va_list args;

    va_start(args, fmt);
    vsnprintf(buf, sizeof(buf), fmt, args);
    va_end(args);

    perror(buf);
    if (fcreated) {
        setregid(real_gid, effective_gid);
	unlink(atfile);
        setregid(effective_gid, real_gid);
    }

    exit(EXIT_FAILURE);
}

void
usage(void)
{
/* Print usage and exit.
 */
    fprintf(stderr, "Usage: at [-V] [-q x] [-f file] [-mMlbv] timespec ...\n"
            "       at [-V] [-q x] [-f file] [-mMlbv] -t time\n"
    	    "       at -c job ...\n"
	    "       atq [-V] [-q x]\n"
	    "       at [ -rd ] job ...\n"
	    "       atrm [-V] job ...\n"
	    "       batch\n");
    exit(EXIT_FAILURE); 

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.