[PR #1375] [CLOSED] fix(browser): reject damaged PNG chunks before screenshot comparison #2837

Closed
opened 2026-10-17 21:10:51 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1375
Author: @rudycelekli
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: fix/png-chunk-validation-current-20261009


📝 Commits (2)

  • b25c616 fix(browser): reject damaged PNG chunks before screenshot comparison
  • 06ff9d5 test(browser): correct simulated capture PNG checksum

📊 Changes

4 files changed (+179 additions, -6 deletions)

View changed files

📝 src/browser/CdpBrowserProvider.ts (+7 -0)
📝 src/browser/PngVisualDiff.test.ts (+137 -0)
📝 src/browser/PngVisualDiff.ts (+34 -5)
📝 tests/fixtures/fakeCdpBrowserResults.ts (+1 -1)

📄 Description

Problem

Screenshot comparison trusted PNG chunks after checking the artifact digest. A real Chrome screenshot with damaged CRC, duplicate header or an unknown critical chunk could be reported as identical even when Chrome could not decode it. Related palette/transparency/chunk-order errors could also produce false pixel comparisons.

Change

Validate chunk CRCs and supported PNG structure before pixel comparison: first/unique IHDR, valid optional PLTE, consecutive IDAT, correctly placed unique tRNS and empty IEND. Keep valid RGB/RGBA, optional palette and ordinary ancillary chunks. Preserve actionable input-format reasons through CLI and MCP instead of suggesting provider repair.

Verification

  • Frozen baseline: five new test scenarios failed; the ten existing controls passed. After: all 15 tests pass. The ordering scenario exercises eight malformed structures and three valid controls.
  • Real Chrome 154 produced the original screenshot and rejected three corrupted variants that baseline REA accepted. Final compiled public CLI and stdio MCP reject all three with invalid_input/invalid_format, while the valid original succeeds.
  • Independent reviewer reran the source suite and native Chrome pixel/decoder oracle: three valid controls remain identical and seven malformed neighbors are rejected. Chrome tolerates some malformed orderings; this does not claim exhaustive PNG conformance or identical decoder policy for every format.
  • npm run check passed; source/test typecheck, formatting and lint passed. Built-in CRC32 availability also checked on supported Node 22.19.0; main tests use pinned Node 24.18.0.
  • Refreshed on current main a9f5dad5: unchanged frozen tests reproduce 5 failures/10 passing controls before, 15 pass after; exact locked dependencies, runtime builds and npm run check pass. Fresh Chrome 154 public CLI/stdio MCP repeat the three rejected-image regressions and valid control. Subsequent main changes through 39dabd06 do not touch either production owner.
  • Hosted verification exposed an invalid IDAT CRC in the simulated CDP screenshot fixture. Corrected only the four checksum bytes, preserving size and pixels; 44 affected PNG/MCP/CLI/provider owners and required check pass. Independent CRC inspection and actual Chrome pixel equality verified. Hosted rerun remains pending.
  • Other PRs/current main exhibit a separate short-circuit alias graph expectation failure, under native-oracle investigation; no production assertion has been weakened to force green.
  • No Hopper/Ghidra execution required/performed. Hosted checks may still be pending.

AI assistance was used for investigation, implementation and verification.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/1375 **Author:** [@rudycelekli](https://github.com/rudycelekli) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/png-chunk-validation-current-20261009` --- ### 📝 Commits (2) - [`b25c616`](https://github.com/morluto/rea/commit/b25c616af951fcce41ef1d161561b3615327b773) fix(browser): reject damaged PNG chunks before screenshot comparison - [`06ff9d5`](https://github.com/morluto/rea/commit/06ff9d5187d05cb4fb4238b6194a9b0bd3e60a3b) test(browser): correct simulated capture PNG checksum ### 📊 Changes **4 files changed** (+179 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/CdpBrowserProvider.ts` (+7 -0) 📝 `src/browser/PngVisualDiff.test.ts` (+137 -0) 📝 `src/browser/PngVisualDiff.ts` (+34 -5) 📝 `tests/fixtures/fakeCdpBrowserResults.ts` (+1 -1) </details> ### 📄 Description ## Problem Screenshot comparison trusted PNG chunks after checking the artifact digest. A real Chrome screenshot with damaged CRC, duplicate header or an unknown critical chunk could be reported as identical even when Chrome could not decode it. Related palette/transparency/chunk-order errors could also produce false pixel comparisons. ## Change Validate chunk CRCs and supported PNG structure before pixel comparison: first/unique IHDR, valid optional PLTE, consecutive IDAT, correctly placed unique tRNS and empty IEND. Keep valid RGB/RGBA, optional palette and ordinary ancillary chunks. Preserve actionable input-format reasons through CLI and MCP instead of suggesting provider repair. ## Verification - Frozen baseline: five new test scenarios failed; the ten existing controls passed. After: all 15 tests pass. The ordering scenario exercises eight malformed structures and three valid controls. - Real Chrome 154 produced the original screenshot and rejected three corrupted variants that baseline REA accepted. Final compiled public CLI and stdio MCP reject all three with invalid_input/invalid_format, while the valid original succeeds. - Independent reviewer reran the source suite and native Chrome pixel/decoder oracle: three valid controls remain identical and seven malformed neighbors are rejected. Chrome tolerates some malformed orderings; this does not claim exhaustive PNG conformance or identical decoder policy for every format. - `npm run check` passed; source/test typecheck, formatting and lint passed. Built-in CRC32 availability also checked on supported Node 22.19.0; main tests use pinned Node 24.18.0. - Refreshed on current main a9f5dad5: unchanged frozen tests reproduce 5 failures/10 passing controls before, 15 pass after; exact locked dependencies, runtime builds and `npm run check` pass. Fresh Chrome 154 public CLI/stdio MCP repeat the three rejected-image regressions and valid control. Subsequent main changes through 39dabd06 do not touch either production owner. - Hosted verification exposed an invalid IDAT CRC in the simulated CDP screenshot fixture. Corrected only the four checksum bytes, preserving size and pixels; 44 affected PNG/MCP/CLI/provider owners and required check pass. Independent CRC inspection and actual Chrome pixel equality verified. Hosted rerun remains pending. - Other PRs/current main exhibit a separate short-circuit alias graph expectation failure, under native-oracle investigation; no production assertion has been weakened to force green. - No Hopper/Ghidra execution required/performed. Hosted checks may still be pending. AI assistance was used for investigation, implementation and verification. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:10:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2837
No description provided.