alpine 3.7
format weakness #27

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:

dunst/src/dunst-1.2.0/src/dbus.c

Context:

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

         fprintf(stderr, "Name Lost. Is Another notification daemon running?\n");
        exit(1);
}

static RawImage * get_raw_image_from_data_hint(GVariant *icon_data)
{
    RawImage *image = g_malloc(sizeof(RawImage));
    GVariant *data_variant;
    gsize expected_len;

    g_variant_get (icon_data,
                   "(iiibii@ay)",
                   &image->width,
                   &image->height,
                   &image->rowstride,
                   &image->has_alpha,
                   &image->bits_per_sample,
                   &image->n_channels,
                   &data_variant);

    expected_len = (image->height - 1) * image->rowstride + image->width
            * ((image->n_channels * image->bits_per_sample + 7) / 8);

    if (expected_len != g_variant_get_size (data_variant)) {
        fprintf(stderr, "Expected image data to be of length %" G_GSIZE_FORMAT
               " but got a " "length of %" G_GSIZE_FORMAT,
               expected_len,
               g_variant_get_size (data_variant));
        g_free(image);
        return NULL;
    }

    image->data = (guchar *) g_memdup (g_variant_get_data (data_variant),
                                g_variant_get_size (data_variant));

    return image;
}

int initdbus(void)
{
        guint owner_id;

        #if !GLIB_CHECK_VERSION(2,35,0)
                g_type_init();
        #endif

        introspection_data = g_dbus_node_info_new_for_xml(introspection_xml,
                                                          NULL);

        owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, 

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.