alpine 3.9
format weakness #17


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, and note that sprintf variations do not always 0-terminate.

File Name:



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

 * The callback scheme allows for use within applications that may have their
 * own particular ways of reporting errors: log files for a web server,
 * perhaps, and an error dialog for a browser.
 * \todo Do we really need such fine-grained control, or just yes/no tracing? */
void rs_trace_to(rs_trace_fn_t *new_impl)
    rs_trace_impl = new_impl;

void rs_trace_set_level(rs_loglevel level)
    rs_trace_level = level;

static void rs_log_va(int flags, char const *fn, char const *fmt, va_list va)
    int level = flags & RS_LOG_PRIMASK;

    if (rs_trace_impl && level <= rs_trace_level) {
        char buf[1000];
        char full_buf[1000];

        vsnprintf(buf, sizeof buf - 1, fmt, va);

        if (flags & RS_LOG_NONAME) {
            snprintf(full_buf, sizeof full_buf - 1, "%s: %s%s\n", MY_NAME,
                     rs_severities[level], buf);
        } else {
            snprintf(full_buf, sizeof full_buf - 1, "%s: %s(%s) %s\n", MY_NAME,
                     rs_severities[level], fn, buf);

        rs_trace_impl(level, full_buf);

/* Called by a macro, used on platforms where we can't determine the calling
   function name. */
void rs_log0_nofn(int level, char const *fmt, ...)
    va_list va;

    va_start(va, fmt);
    rs_log_va(level, PACKAGE, fmt, va);

/* Called by a macro that prepends the calling function name, etc. */ 

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.