Heap Buffer Overflow in tin 2.6.6 via Header Display-Name Quoting
Hello, I am writing to report a heap buffer overflow vulnerability in tin 2.6.6 (2026-05-24), confirmed by code trace against Debian package 2.6.6~20260524-1. Summary of findings: 1. Heap Buffer Overflow via From/To/Cc Header Display-Name Quoting (CVSS 8.1) When tin parses From, To, Cc, Bcc, or Reply-To headers from NNTP articles, parse_mb_list_header() in src/rfc2046.c writes the reformatted address back into the original line buffer. The quote_display_name() function expands the display-name by escaping backslashes and double-quotes (each character is doubled, plus surrounding quotes are added), but the sprintf() call that writes the result back uses a buffer sized for the original, shorter input. A malicious Usenet article with backslashes or double-quote characters in the display-name portion of a From header can trigger a heap buffer overflow when the victim reads the article. The overflow size is proportional to the number of escapable characters, up to ~1023 bytes. This affects all five headers processed through parse_mb_list_header() (From, To, Cc, Bcc, Reply-To). Individual details are attached. I would appreciate an acknowledgment of receipt. Thank you and please let me know if you need anything else. Regards, Tristan ======================================================================== Heap Buffer Overflow via From/To/Cc Header Display-Name Quoting ================================================================ CVSS 3.1: 8.1 (AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:N) CWE: CWE-122 (Heap-based Buffer Overflow) Auth: None (malicious NNTP article) Version: 2.6.6 (2026-05-24, latest; Debian 2.6.6~20260524-1) Validation: Code trace File: src/rfc2046.c, parse_mb_list_header() and quote_display_name() Root Cause: When tin parses From, To, Cc, Bcc, or Reply-To headers from NNTP articles, parse_mb_list_header() writes the reformatted address back into the original line buffer. The problem is that quote_display_name() expands the display-name during quoting, producing output longer than the input, but the output buffer was sized for the original value. parse_mb_list_header() (rfc2046.c:1268) receives buf - a pointer to the dynamic line buffer from tin_fgets(). It saves a write pointer ptr = buf + header_offset, copies the value to a separate buffer, clears *ptr = '\0', then reformats each address back into ptr via sprintf(). For route-style addresses (name <addr>), the display-name passes through gnksa_split_from() (truncates to 1023 bytes), rfc1522_decode() (output <= input length), convert_to_printable() (same length), and finally quote_display_name() - which EXPANDS the string. quote_display_name() (rfc2046.c:1166) wraps the name in double quotes and escapes each backslash and double-quote character by doubling it. For a name consisting of N backslashes, the output is 2*N + 2 bytes (each '\' becomes '\\', plus surrounding '"'). The function correctly allocates the expanded buffer: to = disp_name = my_malloc(len + quote_cnt + 1); *to++ = '"'; while (*ptr) { case '\\': // outputs '\\' for each '\' } *to++ = '"'; But the caller then writes this expanded string back into the original line buffer, which only had space for the unexpanded value: sprintf(ptr, "%s <%s>", new_name, addr); // OVERFLOW For example, a From header with 32 backslashes in the display-name expands to 66 bytes (64 escaped chars + 2 quotes) via quote_display_name(), then sprintf() writes 66 + 3 + strlen(addr) + 1 bytes into a buffer that only had space for the original ~50-byte value. This overflow affects all five headers processed by parse_mb_list_header(): From (line 1399), To (1404), Cc (1409), Bcc (1414), and Reply-To (1434). Impact: A malicious Usenet article or rogue NNTP server causes heap corruption when the victim reads the article. The overflow can corrupt adjacent heap metadata and objects, potentially leading to denial of service (crash) or arbitrary code execution. The overflow size is approximately equal to the number of backslash/double-quote characters in the display-name, up to ~1023 bytes. Trigger: Post an NNTP article with a From header containing many backslashes in the display-name (e.g., 32+ backslashes followed by <attacker@example.com>). The overflow occurs when the victim reads the article in tin.
On Sun, Aug 23, 2026 at 11:24:15PM +0200, Tristan wrote:
A malicious Usenet article with backslashes or double-quote characters in the display-name portion of a From header can trigger a heap buffer overflow when the victim reads the article. The
using the dynamic tin_fgets() buffer (>= 512 bytes) should be "safe" for regular articles, but with malicious input it may ovefflow (I failed to trigger it, even with 2k of \ in From). the following should fix the possible issue: --- a/src/rfc2046.c +++ b/src/rfc2046.c @@ -1274,7 +1274,7 @@ parse_mb_list_header( char name[HEADER_LEN]; char *tmp, *new_name, *disp_name, *ret, *curr_from, *next_from; int type, c_needed = 0; - size_t plen = strlen(pat); + size_t ptr_pos, name_len, ret_len, plen = strlen(pat); char *ptr = buf + plen; /* @@ -1296,7 +1296,9 @@ parse_mb_list_header( return NULL; tmp = curr_from = my_strdup(ptr); - ret = ptr; + ret = my_strdup(ptr); + ret_len = strlen(ret) + 1; + ptr = ret; *ptr = '\0'; do { @@ -1318,6 +1320,13 @@ parse_mb_list_header( else { /* check for problematic strings */ if ((new_name = quote_display_name(disp_name))) { + if ((name_len = strlen(new_name) - strlen(disp_name)) > 0) { + ret_len += name_len; + /* save and restore position in case realloc() creates a new allocation */ + ptr_pos = ptr - ret; + ret = my_realloc(ret, ret_len); + ptr = ret + ptr_pos; + } sprintf(ptr, "%s <%s>", new_name, addr); free(new_name); } else @@ -1398,22 +1407,22 @@ parse_rfc822_headers( unfold_header(line); if ((ptr = parse_mb_list_header(line, "From"))) { FreeIfNeeded(hdr->from); - hdr->from = my_strdup(ptr); + hdr->from = ptr; continue; } if ((ptr = parse_mb_list_header(line, "To"))) { FreeIfNeeded(hdr->to); - hdr->to = my_strdup(ptr); + hdr->to = ptr; continue; } if ((ptr = parse_mb_list_header(line, "Cc"))) { FreeIfNeeded(hdr->cc); - hdr->cc = my_strdup(ptr); + hdr->cc = ptr; continue; } if ((ptr = parse_mb_list_header(line, "Bcc"))) { FreeIfNeeded(hdr->bcc); - hdr->bcc = my_strdup(ptr); + hdr->bcc = ptr; continue; } if ((ptr = parse_header(line, "Date", FALSE, FALSE, FALSE))) { @@ -1433,7 +1442,7 @@ parse_rfc822_headers( } if ((ptr = parse_mb_list_header(line, "Reply-To"))) { FreeIfNeeded(hdr->replyto); - hdr->replyto = my_strdup(ptr); + hdr->replyto = ptr; continue; } if ((ptr = parse_header(line, "Newsgroups", FALSE, FALSE, FALSE))) {
Hi Urs, Thank you for the patch. The fix looks correct -- the key change of tracking the output position and using realloc when the quoted display-name is longer than the original addresses the overflow. For the Reported-by / credit, please use: Tristan Madani Would you like me to request a CVE for this issue? Regards, Tristan
On Mon, Aug 31, 2026 at 01:40:03PM +0200, Tristan wrote:
For the Reported-by / credit, please use: Tristan Madani
There is nothing like that in the changes file.
Would you like me to request a CVE for this issue?
a CVE for something which requires a broken nntp-server beforehand? feel free todo so if you think you can get some fame out of it, I doubt anyone will care ...
participants (3)
-
Tristan -
Urs Janßen -
Urs Janßen