I found a likely memory-safety issue by static source review (no runtime exploit was developed). The technical details are inline below so this report is self-contained, with a full write-up linked within.
Affected component: munt MT-32 emulator, libmt32emu library, MIDI stream parser (class MidiStreamParserImpl / DefaultMidiStreamParser in mt32emu/src/MidiStreamParser.cpp)
Tested version(s): Release tag libmt32emu_2_8_3 (latest release, 2026-06-06), reviewed via raw.githubusercontent.com at that tag. The vulnerable file mt32emu/src/MidiStreamParser.cpp was last modified at commit b341da4 . The same code is present on the dev and master branches. No release tag was fixed at the time of review.
Class: CWE-787 Out-of-bounds Write, CWE-122 Heap-based Buffer Overflow, CWE-131 Incorrect Calculation of Buffer Size.
Summary: The public streaming parser in libmt32emu copies an oversized incomplete SysEx message into a heap buffer that was grown only to a fixed maximum, producing an out-of-bounds heap write whose length and content are controlled by the input.
Root cause (file:line at tag libmt32emu_2_8_3):
Entry point: MidiStreamParserImpl::parseStream, mt32emu/src/MidiStreamParser.cpp:88-116. When the parser buffer is empty and the byte is 0xF0, it calls parseSysex with the full remaining caller length. There is no per-call size limit.
Sink: MidiStreamParserImpl::parseSysex, mt32emu/src/MidiStreamParser.cpp:223-257. The loop scans for the end of the SysEx. If no end byte 0xF7 and no status byte appear, sysexLength reaches the input length. The code then runs streamBufferSize = sysexLength (line 248), calls checkStreamBufferCapacity(false) (line 249), and on a true result copies sysexLength bytes with memcpy(streamBuffer, stream, sysexLength) (line 250).
Incorrect size calculation: MidiStreamParserImpl::checkStreamBufferCapacity, mt32emu/src/MidiStreamParser.cpp:132-143. When streamBufferSize is at least the current capacity and the current capacity is below MAX_STREAM_BUFFER_SIZE, it reallocates the buffer to exactly MAX_STREAM_BUFFER_SIZE and returns true. It never checks that streamBufferSize is less than or equal to MAX_STREAM_BUFFER_SIZE. If sysexLength is larger than 32768, capacity becomes 32768 but the memcpy still copies sysexLength bytes, overrunning the allocation by sysexLength minus 32768 bytes.
Size constants: mt32emu/src/globals.h:122 (MAX_STREAM_BUFFER_SIZE = 32768) and :127 (SYSEX_BUFFER_SIZE = 1000). The default parser capacity is SYSEX_BUFFER_SIZE = 1000 (mt32emu/src/MidiStreamParser.h:64, constructor at MidiStreamParser.cpp:74-76), which is below the maximum, so the grow branch runs under the default configuration.
The overflow bytes come from the SysEx body, which is made of 7-bit data bytes (0x00..0x7F), so both the overflow length and the overflow content are attacker-influenced.
Why sibling paths are safe: the fragment path parseSysexFragment (MidiStreamParser.cpp:260-295) appends one byte per iteration guarded by checkStreamBufferCapacity, so it caps at 32768. The complete-SysEx path dispatches a pointer to handleSysex, reaching Synth::playSysex and MidiEventQueue::pushSysex (Synth.cpp:2283-2297), which by default allocates exactly sysexLength bytes through DynamicSysexDataStorage (Synth.cpp:2160-2171). The defect is confined to the one-shot parseSysex buffering block.
Attacker model: the attacker controls the bytes passed to parseStream, or the MIDI/SysEx data a host forwards to it (a MIDI or SysEx file, a named pipe, a network socket, or a virtual MIDI port). The trigger is one parseStream call carrying a SysEx that starts with 0xF0, holds more than 32768 data bytes in 0x00..0x7F, and never reaches 0xF7 or any other status byte before the block ends. The project documents single-message bulk dumps as a supported use (MidiStreamParser.cpp:130-131), so large one-shot blocks are an intended input.
Impact: out-of-bounds heap write (memory corruption) and denial of service through a crash. The overflow length is bounded only by the input block size minus 32768. This report does not demonstrate remote code execution or information disclosure, which would depend on the allocator and heap layout and were not assessed.
Fix: in checkStreamBufferCapacity, add the condition streamBufferSize < MAX_STREAM_BUFFER_SIZE to the grow branch so an oversized request returns false and parseSysex takes the existing safe branch. As defense in depth, clamp the copy length in parseSysex to the real capacity. A regression test should feed a single parseStream call with a 0xF0 block longer than 32768 bytes that holds no 0xF7 and no status byte and assert no write past the allocation under a heap sanitizer.
Verification: static source review only, at the pinned release tag. The full chain (parseStream to parseSysex to checkStreamBufferCapacity to memcpy) was confirmed against the cited source lines. No repository was cloned, no code was built or executed, no PoC was run, and no live host was contacted. Runtime crash behavior was not observed and is not claimed.
Write-up:
Reported by HaiND (Nguyen Dinh Hai), Post and Telecommunication Institute of Technology, github.com/Haind03.
sergm self-assigned this on Nov 2, 2026
sergm added libmt32emu Security issue on Nov 2, 2026
sergm added the Bug issue type on Nov 2, 2026
sergm added this to the libmt32emu_2_8_4 milestone on Nov 2, 2026
sergm added a commit that references this issue on Nov 2, 2026 mt32emu: Fixed heap buffer overflow in `MidiStreamParserImpl::parseSy… 1749f7f
mt32emu: Fixed heap buffer overflow in `MidiStreamParserImpl::parseSy…
sergm closed this as completed on Nov 3, 2026
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
