fedora 24
format weakness #52

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:

avahi-0.6.32/avahi-compat-libdns_sd/warn.c

Context:

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

                 memmove(exe_name, slash+1, strlen(slash)+1);
        }
    }

    pthread_mutex_unlock(&mutex);

    return exe_name;
#else
#ifdef __GNUC__
#warning "avahi_exe_name() needs to be implemented for your operating system"
#endif
    return "(unknown)";
#endif
}

void avahi_warn(const char *fmt, ...) {
    char msg[512]  = "*** WARNING *** ";
    va_list ap;
    size_t n;

    assert(fmt);

    va_start(ap, fmt);
    n = strlen(msg);
    vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
    va_end(ap);

    fprintf(stderr, "%s\n", msg);

    openlog(avahi_exe_name(), LOG_PID, LOG_USER);
    syslog(LOG_WARNING, "%s", msg);
    closelog();
}

void avahi_warn_linkage(void) {
    int w;

    pthread_mutex_lock(&linkage_mutex);
    w = linkage_warning;
    linkage_warning = 1;
    pthread_mutex_unlock(&linkage_mutex);

    if (!w && !getenv("AVAHI_COMPAT_NOWARN")) {
        avahi_warn("The program '%s' uses the "COMPAT_LAYER" compatibility layer of Avahi.", avahi_exe_name());
        avahi_warn("Please fix your application to use the native API of Avahi!");
        avahi_warn("For more information see <http://0pointer.de/avahi-compat?s="CGI_SUBSYSTEM"&e=%s>", avahi_exe_name());
    }
}

void avahi_warn_unsupported(const char *function) { 

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.