[PR #6412] [MERGED] fix(screenshot): validate complete PNG IHDR #7341

Closed
opened 2026-11-01 21:47:11 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6412
Author: @eco-null
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @morluto

Base: main ← Head: codex/png-ihdr-admission


📝 Commits (1)

  • ee63a82 fix(screenshot): validate complete PNG IHDR

📊 Changes

5 files changed (+101 additions, -2 deletions)

View changed files

📝 src/domain/pngHeader.test.ts (+16 -0)
📝 src/domain/pngHeader.ts (+5 -2)
📝 src/native/NativeUiObservation.test.ts (+14 -0)
📝 tests/boundary/browser/cdpScreenshotDocumentIdentity.test.ts (+32 -0)
📝 tests/boundary/mcp/browserMcp.test.ts (+34 -0)

📄 Description

Summary

Reject incomplete or corrupt PNG IHDR before accepting screenshot dimensions. Fixes #3928. Split from #4040.

Problem and expected behavior

A 24/32-byte header or bad IHDR checksum could be accepted as a screenshot. The shared PNG owner now requires the complete 33-byte IHDR and validates its CRC; both native UI and browser screenshots consume it.

Change and scope

One independent fix on current main; no dependency on #4040. No new target execution or authority.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/pngHeader.ts; header admission before dimension acceptance.
  • Contribution scope fit and linked maintainer decision: Ordinary fix within existing boundaries; new maintainer scope decision not applicable.
  • CLI and MCP/tool-catalog contract: Existing interfaces and schemas retained; observable correction described above.
  • Provider, bridge, target-format, or platform compatibility: PNG parser, native screenshot admission, CDP capture and public MCP error regression; synthetic protocol fixtures, no real renderer.
  • Evidence, artifact, provenance, or reconstruction contract: Incomplete or rejected observations remain explicit; source evidence is retained.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): Existing selection and authority unchanged.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): No build outputs committed; catalogs regenerated by normal checks.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: PNG parser, native screenshot admission, CDP capture and public MCP error regression; synthetic protocol fixtures, no real renderer.
  • Base reproduction or other evidence: New targeted regressions were executed against unchanged main before the production fix; see validation.
  • User-visible CLI/MCP output (if applicable): MCP screenshot failures return unreadable_output with reason protocol_error.
  • Remaining proof gaps: The PNG check is header admission, not full PNG decoding. No real browser/native OS run or cross-platform/full suite proof.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • New targeted tests on unchanged main: 12 failed / 87 passed; after fix: npm run test:focused -- src/domain/pngHeader.test.ts src/native/NativeUiObservation.test.ts tests/boundary/browser/cdpScreenshotDocumentIdentity.test.ts tests/boundary/mcp/browserMcp.test.ts - 99 passed (27.25 s). Full npm run check, normal commit and pre-push passed. Windows, pinned Node 24.18.0/npm 11.16.0; no hosted CI claim.

Compatibility, safety, and release

  • Breaking changes or migration steps: No schema migration; previously misclassified observations are corrected.
  • Real Hopper/Ghidra, browser, or OS coverage: The PNG check is header admission, not full PNG decoding. No real browser/native OS run or cross-platform/full suite proof.
  • Package or release metadata impact: No dependency or release version change.
  • Security, privacy, process, or containment review: No expanded target authority; no bypass of workflow approval.

Author readiness

Human owner: @eco-null

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/6412 **Author:** [@eco-null](https://github.com/eco-null) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `codex/png-ihdr-admission` --- ### 📝 Commits (1) - [`ee63a82`](https://github.com/morluto/rea/commit/ee63a821f4550b51f802cfff24a167e38fb2e25b) fix(screenshot): validate complete PNG IHDR ### 📊 Changes **5 files changed** (+101 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/pngHeader.test.ts` (+16 -0) 📝 `src/domain/pngHeader.ts` (+5 -2) 📝 `src/native/NativeUiObservation.test.ts` (+14 -0) 📝 `tests/boundary/browser/cdpScreenshotDocumentIdentity.test.ts` (+32 -0) 📝 `tests/boundary/mcp/browserMcp.test.ts` (+34 -0) </details> ### 📄 Description <!-- PR title: type(optional-scope): imperative outcome The title becomes the squash-merge commit subject and generated changelog entry. --> ## Summary Reject incomplete or corrupt PNG IHDR before accepting screenshot dimensions. Fixes #3928. Split from #4040. <!-- What user, agent, or maintainer problem does this solve? Link the issue with "Fixes #123" when applicable. Keep the prior behavior, expected contract, and new behavior understandable without private context. --> ## Problem and expected behavior A 24/32-byte header or bad IHDR checksum could be accepted as a screenshot. The shared PNG owner now requires the complete 33-byte IHDR and validates its CRC; both native UI and browser screenshots consume it. <!-- For fixes, give the smallest trigger and violated invariant. For features, describe the use case and observable outcome. --> ## Change and scope One independent fix on current main; no dependency on #4040. No new target execution or authority. <!-- Explain the chosen approach, why it fits REA's architecture, and what is intentionally not included. --> Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Link the required maintainer scope decision for new providers or capabilities involving target execution, injection, mutation, or protection recovery; ordinary fixes within existing boundaries may state "not applicable". Draft PRs may leave the scope decision pending and the readiness and merge checklists unchecked. Maintainers can help resolve open questions. ## Contract and boundary impact <!-- Short answers are welcome. Complete applicable lines; mark unresolved facts as "unknown". Use "none" or "not applicable" only when established. --> - Semantic owner and earliest changed stage: src/domain/pngHeader.ts; header admission before dimension acceptance. - Contribution scope fit and linked maintainer decision: Ordinary fix within existing boundaries; new maintainer scope decision not applicable. - CLI and MCP/tool-catalog contract: Existing interfaces and schemas retained; observable correction described above. - Provider, bridge, target-format, or platform compatibility: PNG parser, native screenshot admission, CDP capture and public MCP error regression; synthetic protocol fixtures, no real renderer. - Evidence, artifact, provenance, or reconstruction contract: Incomplete or rejected observations remain explicit; source evidence is retained. - Target selection, authority, upstream behavior, and cleanup details (if applicable): Existing selection and authority unchanged. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact (CI generates and validates ignored catalogs and `skills/`; edit authored instructions in `.agents/skills/reverse-engineer-anything/` and never commit build outputs): No build outputs committed; catalogs regenerated by normal checks. Expected effects (check known effects; use documentation-only on its own). Unchecked items do not establish absence; leave uncertainties visible. - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage <!-- State whether evidence is executed, source-derived, or proposed. For fixes, show the original failure and explain how the regression would fail on the affected base revision when practical. Include the most useful proof inline; link long logs or artifacts, or put them in optional details. Documentation-only changes can use source, link, or rendered-document checks. --> - Tests added or updated: PNG parser, native screenshot admission, CDP capture and public MCP error regression; synthetic protocol fixtures, no real renderer. - Base reproduction or other evidence: New targeted regressions were executed against unchanged main before the production fix; see validation. - User-visible CLI/MCP output (if applicable): MCP screenshot failures return unreadable_output with reason protocol_error. - Remaining proof gaps: The PNG check is header admission, not full PNG decoding. No real browser/native OS run or cross-platform/full suite proof. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed <!-- List only commands that actually ran, with observed results. Include the relevant real-provider or platform workflow, or explain why it was unavailable. Keep these results current after changes; a command without its result is incomplete. --> - New targeted tests on unchanged main: 12 failed / 87 passed; after fix: `npm run test:focused -- src/domain/pngHeader.test.ts src/native/NativeUiObservation.test.ts tests/boundary/browser/cdpScreenshotDocumentIdentity.test.ts tests/boundary/mcp/browserMcp.test.ts` - 99 passed (27.25 s). Full `npm run check`, normal commit and pre-push passed. Windows, pinned Node 24.18.0/npm 11.16.0; no hosted CI claim. ## Compatibility, safety, and release <!-- Call out breaking changes, migrations, package effects, platform/provider limits, security/privacy/containment implications, and meaningful proof gaps. --> - Breaking changes or migration steps: No schema migration; previously misclassified observations are corrected. <!-- For ! / BREAKING CHANGE: show a previously valid call/configuration, its new behavior and migration, and why compatibility/deprecation cannot preserve it. Every release increments minor, including breaking changes; keep breaking markers and migration notes so callers can assess compatibility. See docs/releasing.md. --> - Real Hopper/Ghidra, browser, or OS coverage: The PNG check is header admission, not full PNG decoding. No real browser/native OS run or cross-platform/full suite proof. - Package or release metadata impact: No dependency or release version change. - Security, privacy, process, or containment review: No expanded target authority; no bypass of workflow approval. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @eco-null - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:11 +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#7341
No description provided.