Bug 2585324 (CVE-2026-137727) - CVE-2026-137727 tnef: Tnef <= 1.4.18 Heap OOB Read in MAPI MIME Tag and Content ID Printing
Summary: CVE-2026-137727 tnef: Tnef <= 1.4.18 Heap OOB Read in MAPI MIME Tag and Conte...
Keywords:
Status: NEW
Alias: CVE-2026-137727
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Product Security DevOps Team
QA Contact:
URL:
Whiteboard:
Depends On: 2585481
Blocks:
TreeView+ depends on / blocked
 
Reported: 2026-11-27 05:54 UTC by OSIDB Bzimport
Modified: 2026-11-27 14:55 UTC (History)
0 users

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description OSIDB Bzimport 2026-11-27 05:54:12 UTC
file_add_mapi_attrs() copies MAPI attachment MIME tags and content IDs into buffers sized from the raw property length, without ensuring that the copied string is NUL-terminated. Printing either field with --list-with-mime-types or -v can read beyond the heap allocation.

Root-Cause Analysis

src/mapi_attr.c:308-322 leaves v->len as the raw MAPI length. For ordinary strings it allocates v->len + 1 and appends a NUL; for Unicode strings it converts the raw bytes to UTF-8 without updating v->len:
v->len = GETINT32(buf+idx);
if (a->type == szMAPI_UNICODE_STRING)
    v->data.buf = (unsigned char*)unicode_to_utf8(v->len, buf+idx);
else {
    v->data.buf = CHECKED_XMALLOC_ADDNULL(unsigned char, v->len);
    memmove(v->data.buf, buf+idx, v->len);
    v->data.buf[v->len] = '\0';
}

src/file.c:196-207 copies exactly a->values[0].len bytes into an equally sized buffer for both MAPI_ATTACH_MIME_TAG and MAPI_ATTACH_CONTENT_ID, discarding any terminator at or beyond that length:
file->mime_type = CHECKED_XMALLOC(char, a->values[0].len);
memmove(file->mime_type, a->values[0].data.buf, a->values[0].len);

The content-ID branch performs the same allocation and copy. src/file.c:159-163 then prints each buffer with %s. A valid UTF-16 value consisting of two U+0800 units and a NUL has raw length 6 but decodes to six non-NUL UTF-8 bytes followed by a NUL at index 6; the six-byte destination lacks that terminator. Conversely, a valid ASCII UTF-16 value such as AB\\0 decodes to AB\\0 in a larger raw-malloc buffer, so copying the raw six-byte length includes three uninitialized bytes after the NUL. 
Steps to Reproduce

    Build tnef with AddressSanitizer:

autoreconf -fi
CC=clang CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address" ./configure
make

    Create a proof-of-concept TNEF file using the script poc_mapi_metadata_overread.py

python3 poc_mapi_metadata_overread.py mime unicode-wide poc-mime-valid.tnef

    Run tnef by feeding the resulting TNEF file:

tnef --list-with-mime-types poc-mime-valid.tnef

    Observe an AddressSanitizer reporting a heap-buffer-overflow, READ of size 5.


Note You need to log in before you can comment on or make changes to this bug.