#30077·opencv

Variant analysis: 1 unfixed sibling safety gap in opencv

Author: x4evexnolCreated Sep 28, 2026Updated Sep 28, 2026
Labelscategory: imgcodecs

Summary

Variant analysis of historical fixes in opencv identified 1 code site where an integer-overflow guard, bounds check, or safe-allocation wrapper exists at one location but is missing at a structurally identical sibling location (same file, same function, or same pattern family) elsewhere in the codebase.

Each finding below is code-confirmed against the current HEAD (verified by cloning the repository fresh and checking the pattern is still present), with the exact file/line locations, the root cause, a description of the trigger path, and — where available — ASan/execution verification output or a proof-of-concept.

Note on origin: these were surfaced by an automated variant-analysis pipeline that diffs historical fix commits against sibling code paths, then has each candidate manually reviewed. I'm posting them together per-project rather than as separate issues to respect maintainer time. Happy to split, close, or reprioritize any of these as you see fit.


Finding 1: OpenCV: null-pointer dereference in GifDecoder::lzwDecode()

Verified against HEAD: a0cda081f8d7 (2026-09-25)

Status: CODE-CONFIRMED, NOT execution-verified.**

Summary

A genuinely novel null-pointer dereference in OpenCV's GIF LZW decoder — the classic "KwKwK" self-referential LZW edge case. The same function had 3 separate OSS-Fuzz fixes (Jan-Mar 2025) that never touched this line. Critically, this is a raw memory-safety crash, not a cv::Exception — it bypasses the harness's exception-catching entirely.

Location

  • modules/imgcodecs/src/grfmt_gif.cpp:381, GifDecoder::lzwDecode()
  • Confirmed at HEAD (2026-09-21)

Root cause

lzwExtraTable[code].prefix[0] dereferences a default-constructed (empty) std::vector<uchar> when the first LZW code after table init/reset equals clearCode+1 (the classic unhandled LZW "KwKwK" self-referential edge case). No bounds check, no default member initializer.

Sibling-gap quality

Strong: this exact function had 3 OSS-Fuzz-driven fixes (PRs #27081, #27138, commit 1f468dd586, Jan-Mar 2025) for adjacent bugs in the same LZW table-growth logic. git blame confirms the vulnerable line was never touched by any of those three fixes.

Harness bypass

The fuzz harness catches cv::Exception but this is a raw segfault/signal — bypasses the harness's exception handling entirely, registering as a genuine fuzzer crash.

Caveat

This file is under continuous active OSS-Fuzz pressure — there's some chance this sits unpublished in Google's private issue tracker already. No public fix exists as of 2026-09-21, so treated as novel for this exercise but flagged.


Methodology

For each historical vulnerability fix in the codebase, we identified the safe pattern the fix introduced (an overflow guard, a safe allocator wrapper, a bounds check) and searched the rest of the codebase for structurally identical code that predates or postdates the fix but never received it. Each candidate was then manually verified against the current HEAD listed above.

Happy to provide anything else that would help triage — additional PoC inputs, a minimal patch following the existing safe-sibling pattern, or a written reproduction script.