Matt Jesc — security writeups

One zero byte: a divide-by-zero in GNU mtools (CVE-2026-137327)

2026-11 · Matt Jesc, Nodejam · tags: mtools, FAT, denial of service, disclosure

TL;DR: mtools divides by the boot sector's sectors-per-cluster field without checking it for zero. Flip that one byte to 0x00 in an otherwise valid FAT image and mdir, minfo and mtype abort with SIGFPE on x86_64 on every version I tested from 4.0.32 to 4.0.50 (4.0.23 aborts for mdir and mtype only). I disclosed it on the info-mtools list on 2026-11-03 with a tested patch and a working reproducer image. VulnCheck published CVE-2026-137327 on 2026-11-26 with finder credit.

All reproduction steps were verified hands-on against pinned versions; every referenced artifact is public or reconstructable from public material.

The bug

The boot sector's sectors-per-cluster byte feeds cluster_size, and cluster_size feeds this division in init.c, calc_num_clus():

Fs->num_clus = (tot_sectors - Fs->clus_start) / Fs->cluster_size;

Nothing above it rejects zero. On x86_64 an integer division by zero raises SIGFPE, so every command that opens the image dies before it prints anything.

The reproducer

Take a valid 1.44 MB FAT image and set byte 13 (sectors per cluster) to 0x00. The image is 1,474,560 bytes, sha256 38198b0fe2c34d79bea8d9414ced9e359525ac6784dde59cf843b044c5559ce6. On Debian's own 4.0.32 package and on builds of 4.0.32, 4.0.42, 4.0.47, 4.0.49 and 4.0.50:

mdir  -i spc0.img ::    exits 136 (SIGFPE)
minfo -i spc0.img ::    exits 136 (SIGFPE)
mtype -i spc0.img ::    exits 136 (SIGFPE)

The unchanged image exits 0. Version 4.0.23 crashes the same way for mdir and mtype (the division then lived in fat.c); minfo does not, because in that release it does not reach the division.

Two honest limits, both stated in the original post. First, the crash is x86_64 specific: the same image on arm64 does not trap, because ARM does not raise a fault on integer divide by zero. Debian's arm64 4.0.26 under qemu user-mode exits 0 for mdir and minfo and exits 1 without a signal for mtype. Second, this is a denial of service in a command-line utility, not memory corruption: nothing is written out of bounds and the abort ends the run.

Disclosure and record

I posted the full reproduction, the patch and the reproducer image to the info-mtools list on 2026-11-03, offered maintainers to file the CVE request themselves, and named a fallback request path after a grace window. The post also names the neighboring CVE-2026-118384 (an out-of-bounds write in parse_vses, fixed in 4.0.50) so nobody files the two as one bug: different file, function and trigger.

VulnCheck assigned CVE-2026-137327, published 2026-11-26: "GNU mtools through 4.0.50 Divide-by-Zero via Sectors-per-Cluster in calc_num_clus()", CWE-369, finder credited as "Matt Jesc (Nodejam)". The CNA's published scoring is CVSS:4.0 4.8 (AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:L) and CVSS:3.1 3.3 (AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L): local attack, availability only, which matches the bug. The affected range ends at 4.0.50, the current release, and the record carries no upstream fix commit as of publication.

Credits

Finder: Matt Jesc. CNA of record: VulnCheck. The public record runs list disclosure 2026-11-03, CVE publication 2026-11-26.