Misaligned pointer store in ht_undo_impl() (HTJ2K decode, internal_ht.cpp)
Description
Misaligned int32_t pointer store in ht_undo_impl() (HTJ2K/HT decode path, internal_ht.cpp). Decoding a crafted HT-compressed EXR chunk whose channels sum to a non-4-byte-aligned bytes-per-scanline stride can write a 4-byte pixel value through a pointer that isn't 4-byte aligned. Confirmed reproducible via UndefinedBehaviorSanitizer on every run, verified against the actual crash input's real channel layout with debug instrumentation (not just theory). Same bug class as the already CVE-rated CVE-2026-34379 (misaligned write in LossyDctDecoder_execute).
Details
ht_undo_impl() in src/lib/OpenEXRCore/internal_ht.cpp computes bpl (bytes per scanline) as sum(bytes_per_element * width) across all channels, with no alignment enforcement:
int64_t bpl = 0;
for (int16_t c = 0; c < decode->channel_count; c++)
bpl += (int64_t) decode->channels[c].bytes_per_element *
(int64_t) decode->channels[c].width;Each scanline row advances the destination pointer by line_pixels += bpl. Row 0 starts aligned (base allocation), but if bpl is not a multiple of 4, every subsequent row's base address drifts out of 4-byte alignment. A 4-byte channel (FLOAT/UINT) written first in that row inherits the row's misalignment:
int32_t* channel_pixels =
(int32_t*) (line_pixels + cs_to_file_ch[c].raster_line_offset);
...
*channel_pixels++ = cur_line->i32[p]; // misaligned store, UBConfirmed with instrumented output on the actual crash input: 4 channels A(UINT,4B) B/G/R(HALF,2B), each 587px wide (odd width) → bpl = 4*587 + 2*587*3 = 5870, and 5870 mod 4 == 2. On row 1 the row base is offset by 5870 bytes (only 2-byte aligned), and channel A — first in row order, raster_line_offset == 0 — inherits that misalignment directly. This is a cross-row stride issue, not an intra-row channel-offset issue.
UBSan output, with full call stack confirming reachability through the public read API:
internal_ht.cpp:353:25: runtime error: store to misaligned address ... for type 'int32_t' (aka 'int'), which requires 4 byte alignment SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior internal_ht.cpp:353:25
#0 ht_undo_impl(...) internal_ht.cpp:353 #1 internal_exr_undo_ht internal_ht.cpp:376 #2 exr_uncompress_chunk compression.c:546 #3 exr_decoding_run decoding.c:598 #4 ScanLineProcess::run_decode ImfScanLineInputFile.cpp:587 #5 ScanLineInputFile::Data::readPixels ImfScanLineInputFile.cpp:501 #6 InputFile::Data::readPixels ImfInputFile.cpp:458
This is the same function as three previously fixed CVEs (2026-44663 int overflow, 2026-45696 heap-OOB read, 2026-39886 signed int overflow, all fixed by 3.4.12). This is a distinct, still-open bug on top of current main (verified post all three fixes against CHANGES.md).
Same bug class as CVE-2026-34379 ("Misaligned write in LossyDctDecoder_execute leading to undefined behavior", CVSS 7.1 High): an unaligned pointer cast dereferenced during pixel decode. Requesting a CVE on that precedent.
Suggested fix: pad bpl up to a 4-byte (alignof(int32_t)) multiple so every row starts aligned, or copy through memcpy instead of a typed pointer dereference for the non-HALF branch. Rounding raster_line_offset alone would not fix this — the misalignment comes from the cross-row bpl stride, not the intra-row channel offset.
PoC
Found via libFuzzer (openexr_exrcheck_fuzzer, corpus corpus-ht/), independently reproduced by all 22 parallel fuzz workers, and reconfirmed by direct rerun against a freshly rebuilt library plus targeted instrumentation of the crash site. I have a 428KB crash input on hand (and can minimize it further); not able to attach it through this form — happy to send it another way (gist, email) if useful.
Reproduction path: any code path that reaches ht_undo_impl() with an HT-compressed chunk whose channels sum to a bytes-per-scanline stride (bpl) that is not a multiple of 4 will trigger the misaligned store on some row of decode (e.g. via exrcheck / InputFile::readPixels on the crafted file). Concretely: 4 channels A(UINT) B/G/R(HALF), image width 587 (odd), yields bpl=5870, not 4-aligned.
Impact
Undefined behavior (misaligned pointer dereference) reachable by decoding an untrusted, crafted HT-compressed EXR file through the public read API (InputFile::readPixels / checkOpenEXRFile). Same class as CVE-2026-34379: crash/DoS on alignment-enforcing architectures (ARM, RISC-V, MIPS), and possible silent data corruption on x86 under compiler optimizations that assume alignment.