Signature detection succeeded before decoding failed.
CyberChef’s View Bit Plane operation first checks whether input looks like an image and then asks Jimp to decode it. A malformed PNG can preserve the PNG magic bytes while corrupting required internal structure. In the public reproduction for issue #2504, the required first IHDR chunk was changed to IBDR.
The signature-level isImage() check still identified the input as PNG, but Jimp.read() and its PNG decoder rejected the structure. PR #2612, authored by Zain Nadeem, made that second validation boundary explicit.
A dependency parser error appeared as an unexpected operation failure.
The operation already returned a clear OperationError when input did not have a recognized image signature. Once input passed that preliminary check, however, a decoder exception propagated as a plain error. Malformed but recognizable files therefore followed a different error path from clearly non-image input.
The preliminary check and full parser establish different facts.
A magic-byte check can classify likely file type, but it cannot establish that all required chunks, lengths, and stream structure are valid. The operation treated a positive signature check as sufficient to call the decoder without an error conversion boundary.
Wrap only image loading and retain the decoder message.
The merged patch separates argument setup from image loading, catches errors from Jimp.read(input), and raises an OperationError formatted as Error loading image. (<original error>). Processing after a successful decode is unchanged.
try {
parsedImage = await Jimp.read(input);
} catch (error) {
throw new OperationError(`Error loading image. (${error})`);
}Corrupt structure while preserving the signature.
The regression derives malformed input from a valid PNG fixture by replacing the hexadecimal IHDR marker with IBDR. The recipe decodes the hex, runs View Bit Plane, and asserts the expected operation-error output. The upstream record documents all 2,057 operation tests passing.
This fixture targets the boundary precisely: it ensures the initial file-type test succeeds, so the test reaches and protects the decoder failure path added by the patch.
Detection and validation should not be treated as interchangeable.
- File signatures identify formats; full decoders establish structural validity.
- Wrap parser boundaries at the operation layer so malformed input remains an expected user error.
- Useful regression fixtures preserve the condition that reaches the failing layer instead of being rejected earlier.
- Retaining the original decoder text can aid diagnosis while the application controls presentation.