Skip to content

fix(screenshot): validate complete PNG IHDR - #6412

Merged
morluto merged 1 commit into
morluto:mainfrom
eco-null:codex/png-ihdr-admission
Oct 23, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
eco-null:codex/png-ihdr-admission

Conversation

@eco-null

@eco-null eco-null commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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.

@eco-null
eco-null marked this pull request as ready for review October 22, 2026 22:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-22T22:43:19.998657Z
We couldn’t complete this review. Comment @codex review to try again.
ee63a82 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable defects were found.

Summary

readPngHeaderDimensions now requires all 33 bytes of the PNG header and checks the IHDR checksum before accepting dimensions.

  • Native and browser screenshots require a complete, CRC-checked PNG header.

Reviews (1) · Last reviewed commit: "fix(screenshot): validate complete PNG I..." · Reviewed by Greptile

@morluto
morluto merged commit 3e85da9 into morluto:main Oct 23, 2026
45 of 46 checks passed
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] capture-web-screenshot accepts truncated IHDR bytes as a successful PNG

2 participants