You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VMime uuencode decoder: an unsigned underflow of the read length drives an out-of-bounds write on the stack while decoding a crafted MIME body #362
The write-up gives the exact file and line of the sink, the reachability chain from the public entry point, an honest impact assessment, and a suggested fix. I am happy to send a patch or any further detail.
Reported by HaiND (Nguyen Dinh Hai), Post and Telecommunication Institute of Technology, github.com/Haind03.
Thank you for the report and for the detailed write-up, it made the issue easy to confirm and fix.
I confirm both findings. I checked the trace against the source and it holds:
Finding 1: when a line starts with b but is not a begin line, the probe leaves inPos at 5 while inLength is 2, and inLength - inPos wraps around. The two stream adapters then pass the huge count through, because their bounds checks (pos + count >= end) overflow too.
Finding 2: with a line length above 48, out.write() emits up to 15 bytes of outBuffer that were never written.
the decoder stops when the marker probe has consumed more than the line holds, and the line length is clamped so that only decoded bytes are written out;
inputStreamStringAdapter and seekableInputStreamRegionAdapter now compare the count with the remaining bytes, so a wrapped count can no longer get through to the copy;
regression tests cover both cases, as well as the adapters.
While I was in this code, I also fixed some decoding bugs: lines whose length is not a multiple of 3 were not read entirely, the filename from the begin line included the mode, and a begin line with no mode and no filename swallowed the next line.
You are credited in the commit message. If you have time to look at the PR, feedback is welcome.
Activity
uuEncoder: fix out-of-bounds write and several decoding bugs
vincent-richard commentedon Oct 22, 2026
Hi @Haind03,
Thank you for the report and for the detailed write-up, it made the issue easy to confirm and fix.
I confirm both findings. I checked the trace against the source and it holds:
bbut is not abeginline, the probe leavesinPosat 5 whileinLengthis 2, andinLength - inPoswraps around. The two stream adapters then pass the huge count through, because their bounds checks (pos + count >= end) overflow too.out.write()emits up to 15 bytes ofoutBufferthat were never written.The fix is in #363:
inputStreamStringAdapterandseekableInputStreamRegionAdapternow compare the count with the remaining bytes, so a wrapped count can no longer get through to the copy;While I was in this code, I also fixed some decoding bugs: lines whose length is not a multiple of 3 were not read entirely, the filename from the
beginline included the mode, and abeginline with no mode and no filename swallowed the next line.You are credited in the commit message. If you have time to look at the PR, feedback is welcome.
Thanks again!