fcl-images: A lot of bugs in most formats, leading to crashes, timeouts, wrong behavior. Code execution in PSD.

Hello, I wanted to report some issues with fcl-image. I will say it directly: all of the issues were found and confirmed by GPT 5.3 Codex + GPT 5.4 in Codex. I'll also attach the raw reports/PoC folders. I hope this is useful, those are not hallucinations. And, as far as I know, Lazarus uses fcl-image in TImage, so those issues apply to a lot of programs. Also, it's likely that no one really uses the PSD decoder (Lazarus doesn't use it), but it's still included in the report.

The separate reports + PoC images + LLM writeups are in this archive: fpc_review_sanitized.zip

The report below is a concatenated report of all findings, LLM-written:

fcl-image: consolidated reader/writer issues across BMP, GIF, JPEG, PNG, PNM, PSD, TGA, TIFF, and XPM

Tested against upstream origin/main at d50c80a77e21c0f8dab68257ed6f146aedf57a70.

This consolidates the confirmed findings from the review reports in reports/, the repro corpus in pocs/fclimage/, and the PSD lab notes in psd/.

Critical

PSD

  • Indexed palette length is unchecked, and palette parsing can overrun a fixed stack buffer. Affected: fpreadpsd.pas:L163, fpreadpsd.pas:L167, fpreadpsd.pas:L171. PoC: pocs/fclimage/psd/cases/indexed_palette_overflow_1024.psd. Additional context: psd/findings.md shows saved return-address overwrite and same-process control-flow redirection in a lab build; the same parser family also has unchecked resource-block walking in fpreadpsd.pas:L283 through fpreadpsd.pas:L316.

High

BMP

GIF

JPEG

PNG

PNM

PSD

TGA

TIFF

XPM

Medium

BMP

GIF

JPEG

PNG

PNM

PSD

TGA

TIFF

XPM

Low

BMP

GIF

JPEG

PNG

PNM

  • ASCII PBM accepts values other than 0 and 1 and silently coerces them. Affected: fpreadpnm.pp:L251, fpreadpnm.pp:L252. PoC: pocs/fclimage/pnm/cases/pbm_value_2_becomes_white.pbm.

PSD

TGA

TIFF

XPM

  • Odd-length hexadecimal colors are silently truncated instead of rejected. Affected: fpreadxpm.pp:L90, fpreadxpm.pp:L94. PoC: pocs/fclimage/xpm/cases/odd_hex_len_1234.xpm.