Matt Jesc — security writeups

The fix moved the bug: a complete incomplete-fix arc on FLTK (CVE-2026-116724)

2026-11-22, updated 2026-11-28 · Matt Jesc, Nodejam · tags: FLTK, BMP, incomplete fix, verification, memory corruption

TL;DR: The upstream fix for CVE-2026-116724 (FLTK BMP image loader, heap buffer overflow) closed the allocation overflow but left the row-pointer arithmetic in the same function computing in 32 bits. A 118-byte file still wrote outside the buffer on the fixed build. I reported the gap as fltk/fltk #1647 with a tested fix shape, the maintainer shipped a two-site fix in about 49 hours, I rebuilt and replayed every shape clean under AddressSanitizer, and we closed the issue together at about 56 hours. The gap is now CVE-2026-135433, and its public record runs report, fix, independent verification, close.

All reproduction steps were verified hands-on against pinned versions; every referenced artifact is public or reconstructable from public material. This writeup covers a follow-up to the bugs HaiND (@Haind03) reported in issue #1632, published by VulnCheck, the CNA, as CVE-2026-116723 and CVE-2026-116724; the incomplete-fix gap below is mine.

Why I was reading someone else’s fix

Every detector in our pipeline has to earn trust before it touches anything real: it must fire on a build known to be vulnerable, and it must load clean on a build known to be fixed. The cheapest source of both builds is a fresh CVE fix. On 2026-10-22, FLTK landed commit 3a049d8262dc759cf9737339420e8457e24c0cb1, closing issue #1632: a stack and a heap buffer overflow in the BMP image loader, found by HaiND (@Haind03) and published by VulnCheck, the CNA, as CVE-2026-116723 (the stack overflow) and CVE-2026-116724 (the heap allocation overflow). A public diff for a defect fixed days earlier is exactly what calibration input looks like.

So I built the canary pair on FLTK release-1.4.5 (a9b1113): a 1,670-byte BMP whose colormap overflows the 768-byte stack array, and two builds under AddressSanitizer, one without the fix and one with 3a049d8 applied by hand (the patch does not apply to that tag as a diff). The canary behaved. It fired on the unfixed build. With the fix applied it loaded clean, loaded w=1 h=0, exit 0, five runs out of five.

Then I did the step that produced everything else in this story: I read the rest of the function the fix did not touch.

The half that moved

3a049d8 makes two changes to load_bmp_ in src/Fl_BMP_Image.cxx. It bounds colors_used at 256, which closes the colormap overflow. And it promotes the pixel-buffer allocation to 64 bits:

-  array = new uchar[width * height * dstBDepth];
+  array = new uchar[(size_t)width * height * dstBDepth];

Below it, the per-row pointer still computes its offset in 32 bits:

for (y = start_y; y != end_y; y += row_order) {
    ptr = (uchar *)array + y * width * bDepth;      /* release-1.4.5, line 304 */

y, width and bDepth are all int, so y * width * bDepth wraps exactly the way the allocation used to. ptr is set from it on the first row, before any pixel is read, and a tall image overflows the product immediately.

The input that shows it is 118 bytes long. poc-alloc.bmp declares width 2, height 715,827,883, depth 24, so width * height * 3 = 4,294,967,298 = 2^32 + 2. Measured both ways, five runs each:

BuildASanAllocationFault site
release-1.4.5, no fixheap-buffer-overflow, 5 of 5, exit 1342-byte regionFl_BMP_Image.cxx:486
same tree + 3a049d8heap-buffer-overflow, 5 of 5, exit 1344,294,967,298-byte regionFl_BMP_Image.cxx:490

AddressSanitizer’s two verdicts, verbatim:

0x60200000258e is located 2 bytes before 2-byte region [0x602000002590,0x602000002592)
0x00010d0697fe is located 2 bytes before 4294967298-byte region [0x00010d069800,0x00020d069802)

Same geometry, different region. The fix did not remove the defect; it moved it, from “undersized allocation” to “correct allocation, wrong pointer”. Same arithmetic class, same function, the wrapped expression sitting in the scanline loop below the allocation. The fix also carried a side effect worth naming plainly: the same 118-byte file that used to request a 2-byte allocation now requests 4 GB.

It was not one input. Two more 118-byte shapes fired on the fixed tree: 6 x 238,609,295 at depth 24 (region 4,294,967,310 bytes, fault at :490) and 4 x 268,435,457 at depth 32 (region 4,294,967,312 bytes, fault at :503). The depth-32 shape reaches a different branch of the decode switch, so the wrap is not tied to the 24-bit path: every branch that writes through ptr inherits it.

The report

I filed the gap as fltk/fltk issue #1647 on 2026-11-19. The discipline I hold public reports to, all in one issue:

-    ptr = (uchar *)array + y * width * bDepth;
+    ptr = (uchar *)array + (size_t)y * width * bDepth;

That cast was not a proposal. I had applied it to the 1.4.5 tree carrying 3a049d8 and run it: the 118-byte file went from heap-buffer-overflow at :490, exit 134, to exit 0 with no sanitizer report, three of three, and the original colormap canary stayed clean.

Also honest: the first PoC attempt, a wide short image, did not fault. The wrap needs a tall image, because y is what grows. That dead end is in the issue too.

The generator fits in ten lines, and the issue carries it:

import struct
width, height, depth = 2, 715827883, 24      # width*height*3 == 2**32 + 2
pixels = b"\x41" * 64; off = 54
hdr  = b"BM" + struct.pack("<I", off+len(pixels)) + b"\x00\x00\x00\x00" + struct.pack("<I", off)
hdr += struct.pack("<I", 40) + struct.pack("<i", width) + struct.pack("<i", height)
hdr += struct.pack("<H", 1) + struct.pack("<H", depth) + struct.pack("<I", 0)
hdr += struct.pack("<I", len(pixels)) + struct.pack("<i", 0) + struct.pack("<i", 0)
hdr += struct.pack("<I", 0) + struct.pack("<I", 0)
open("poc-alloc.bmp", "wb").write(hdr + pixels)

The surface is a local file and a constructor: Fl_BMP_Image(const char*) opens it, no network, no privilege. Whoever supplies the file owns the fault.

The fix

About 49 hours after the report, on 2026-11-21, ManoloFLTK committed a28e3927faebaba7d33f740d13e88fa0e22fd64d, “BMP image loader: fix potential issue with crafted image file (#1647)”. Two lines changed, both in load_bmp_:

That is what reporting the mechanism instead of the input buys. The report cast one expression and noted the multiply had another copy further down; the commit cleaned up the class.

Two minutes after the commit, the reply: “Commit a28e392 should fix this issue as well as another similar downstream. Please, close issue if you confirm the fix.” Verification handed back to the reporter, where it belongs.

The verification

I rebuilt FLTK from source at a28e392, cmake with -fsanitize=address -g -O1, static libs, and confirmed both patched lines in the tree (344 and 560). The driver is the report’s driver shape: construct Fl_BMP_Image from the filename, print, delete. Then the replay, five runs per input:

inputshapetree with only 3a049d8a28e392
poc.bmpthe #1632 colormap canaryclean, by designclean 5/5, exit 0
poc-alloc.bmpwidth 2, height 715,827,883, depth 24heap-buffer-overflow 5/5clean 5/5, exit 0, loaded w=2 h=0
poc-b.bmp6 x 238,609,295, depth 24heap-buffer-overflow 5/5clean 5/5
poc-c.bmp4 x 268,435,457, depth 32heap-buffer-overflow 5/5clean 5/5

The positive control matters as much as the clean column. The three PoC files are sha256-pinned and unchanged since October, and those exact bytes fired 5/5 on the tree carrying only the allocation fix, in recorded logs. A replay where the family stayed clean on that tree would mean my harness had broken. It fired, so the clean column means something.

I posted the table as a comment on the issue and closed it as completed, 2026-11-21 19:49 UTC, per the maintainer’s ask. Filing to verified close: about 56 hours, of which the maintainer’s share was about 49 and mine was one evening.

The residual, named once

An 118-byte file still asks load_bmp_ for a 4,294,967,298-byte allocation. The loader applies no sanity bound on height. The out-of-bounds write is closed; the memory-exhaustion attempt is a design property, not part of this defect, and it is the maintainer’s call. It is named in the issue once, neutrally, and that is where it stands. VulnCheck published the row-pointer wrap itself as CVE-2026-135433 on 2026-11-23, crediting me as finder.

The lesson

Two, one for each hat.

If you consume advisories: “fixed in 3a049d8” was a true statement for six days before it was a complete one. A fix commit closes the expressions it touches. The same arithmetic class, in the same function, below the changed line, is a different expression and stays open. Version notes, scanner banners and “patched” badges all inherit this gap. The habit that catches it: read the whole function a fix lands in, not just the hunks.

If you do the research: verification is a contribution, and an undersold one. The cost side of this arc was small: one rebuild, one replay table, one comment, one close. The value side: a maintainer got a confirmed close instead of a dangling question, a second latent site got fixed in the same commit, and the public record of CVE-2026-135433, the row-pointer wrap, runs report, fix, independent verification, close, all inside 56 hours. The canary found the gap. The discipline of proving a fix against a control closed it.

Credits: HaiND found and reported CVE-2026-116723 and CVE-2026-116724 (issue #1632). ManoloFLTK turned the follow-up around in about 49 hours and fixed a second site unprompted. VulnCheck is the CNA of record. The row-pointer wrap reported in issue #1647 is now CVE-2026-135433, published 2026-11-23.