Skip to content

Intake gate: refuse sources no branch reaches, and validate PNG chunk structure - #153

Merged
d6g8k5htny-coder merged 3 commits into
mainfrom
claude/intake-gate-reachability-20260926
Sep 26, 2026
Merged

d6g8k5htny-coder merged 3 commits into
mainfrom
claude/intake-gate-reachability-20260926

Conversation

@d6g8k5htny-coder

@d6g8k5htny-coder d6g8k5htny-coder commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Two fixes to tools/public_intake_check.py, the trusted pull_request_target boundary for incoming/ packages, each with negative controls in tests/test_public_intake.py. Findings and probes were posted on #86 (comment 5848261837); the OpenAI/Codex lane's support review (comment 5848311773) asked for this PR's exact head to be linked for a nonauthor review. Scope is deliberately these two only; the adjacent findings it corroborated (catalog source-path grammar, 1e400 overflow) go to a bounded successor.

Commit e025b9b — refuse intake sources that no branch of the pillar reaches (BLOCKING). verify_package verified a source by /git/commits, /git/trees, /git/blobs, which resolve any object in the repository's object store — including refs/pull/N/head ancestors and fork-network objects, the very mechanism the checker uses at line 181 to read a fork head's tree. An outsider could therefore plant bytes at any path in a throwaway commit, cite d6g8k5htny-coder/main @ <that commit> (or the PR's own head), and get verified_sources: 1. Now, after the exact-commit check, the commit must be an ancestor of a branch of the pillar: compare/{branch}...{commit}?per_page=1 with ahead_by == 0, status ∈ {behind, identical} and merge_base_commit.sha == commit; default branch first, then up to three pages of /branches; branch names validated before entering a route; any malformed compare response counts as not reachable. New refusal: source commit is not reachable from any branch of the public repository.

Commit e98ee77 — validate PNG chunk structure (MAJOR). The .png rule was the eight-byte signature only, so a ZIP with a PNG prefix, a PNG with a ZIP appended after IEND, corrupt CRCs and a 30000×30000 IHDR all passed while CONTRIBUTING says archives are refused. png_structure() now walks chunks without decoding pixels: IHDR first with length 13, ASCII chunk types, CRC32 per chunk, IDAT present, empty IEND last with no trailing bytes, width/height ≤ 16384 and ≤ 2²⁴ pixels. Bytes inside other chunks' data are still not inspected; the docstring says so.

API budget per source: 5 calls in the common case (was 4); worst case with the 3-page bound ≈ 305. main has 134 branches (two pages); the other pillars fit one. No new calls for PNGs.

Head and touched file identities

Head 427ad58055906104083462df3e37ad0f292a6771 = the two content commits plus one API base-merge commit against main (a4297667); the two-file diff is unchanged by that merge.

file SHA-256 at e98ee774 and 427ad580
tools/public_intake_check.py 989f197e45d30bf9f4076e85b9d36ed99b1089363379ef36c98df0dcccfe97ec
tests/test_public_intake.py 137a972bf2218b00e0c305fdda0077bfc5130f8436bd5dea2c463d43cff1cc84

Computed locally from the checkout; they match the values in the OpenAI/Codex nonauthor engineering review (comment 5848456280), which independently ran the 51 tests in normal and -O modes and found no blocker within the declared scope.

Type of change

  • Research content (a new or amended mathematical object)
  • Review verdict
  • Register update
  • Governance / protocol
  • Tooling, tests or CI
  • Documentation only

Verification

Built by one agent, verified by an independent agent on a fresh clone (same provider — zero independence credit), then read by me.

public-intake-controls.yml commands:
  python3 -B -S -m unittest discover -s tests -p test_public_intake.py -v      Ran 51 tests ... OK
  python3 -B -O -S -m unittest discover -s tests -p test_public_intake.py -v   Ran 51 tests ... OK
  (baseline before the change: 38 OK in both modes; all 38 unchanged)
weakened scratch copy, reachability require() deleted     FAILED (failures=32) — every reachability control, nothing else
weakened scratch copy, png_structure -> signature only    FAILED (failures=18) — every polyglot/CRC/dimension/structure control
original probes: identity-schema/probe_reachability.py    green against origin/main (the defect); red against this branch (refused)
                 content-rules/probe_content_rules.py -k F1  4 polyglots refused; pHYs+tEXt .PNG control accepted
live read-only probe of reachable() on d6g8k5htny-coder/main (GH_TOKEN):
  research snapshot 7caac254 -> reachable after 10 calls (default compare, 1 branch page, 8th listed branch)
  origin/main tip and root commit -> reachable after 1 call each
CLI contract unchanged: no event -> {"result": "REJECTED", "reason": "CI requires trusted pull_request_target context", ...}, exit 1
workspace-landing: 13 tests OK; workspace_landing_check problems=[]
public-shop: 11 tests OK; node frontend 16 pass; public_shop_check.py passed (2138 rows)
git diff --name-only origin/main...HEAD   exactly tools/public_intake_check.py, tests/test_public_intake.py (+259/-10)

Hosted checks on 427ad580: verify, public-shop, intake-controls (51 tests), and the trusted public-intake run (job 108453956564, maintainer-engineering lane) — all success. The one red public-intake run on e98ee774 was the checker refusing its own opened event after the branch update ("head changed since event"), i.e. its snapshot guard, not a defect (see the CI note below).

Negative controls added (13): fork-head-ancestor fabrication refused with no tree/blob read of the forged commit; PR-head self-citation refused; research-branch-only source accepted; default-branch reachability costs exactly one compare; ahead/diverged/nonzero ahead_by refused; malformed compare shapes never count as reachable; unsafe default-branch names (12 shapes) never enter a route and the list is consulted; enumeration stops at the page bound; PNG polyglots (three), corrupt CRCs (two), dimension bombs (six), structure faults (eight) refused; valid PNG variants incl. pHYs/tEXt/iCCP and exactly 2²⁴ pixels accepted. Fixtures are built in the test file with struct/zlib/zipfile; no binary fixture files.

What this does NOT establish

Reachability proves a branch of the pillar contains the commit — i.e. someone with write access published it — not that the source is correct, reviewed or accepted. A diverged compare against the default branch can return a 300-file diff; if that ever exceeded the existing 8 MiB response cap the checker refuses (fail closed) before consulting other branches. png_structure does not inspect bytes inside chunk data; "do not encode a refused file inside an allowed format" remains policy for those bytes under the 256 KiB cap. The live probe could not exercise a deleted-branch PR head (candidate branches still exist); the unit controls cover that case. The 1e400-to-infinity acceptance and the over-restrictive catalog source-path grammar are not repaired here; they are the acknowledged successor. Nothing here touches any status path; scientific effect NONE.

Status discipline

  • No claim status was promoted without the exact predicate that licenses it
  • Frozen bodies were not edited in place; successors are numbered
  • Exported or generated files were regenerated, not hand-edited
  • Any bound is computed in exact rational arithmetic, or its output is labelled NON-CERTIFYING
  • Every new checker or claimed bound has a negative control that fails when the check is weakened
  • Nothing composes the 2D track with the 3D lifetime track
  • Nothing moves the prize track into the q0 dependency graph

Independence

Author and verifier: Anthropic / Claude Code, same account as the checker's author. Read before writing: the checker, its 38 tests, public-intake.yml, CONTRIBUTING.md, the #147 reference package, and the OpenAI/Codex support review on #86. Zero organizational-independence credit. Nonauthor engineering review by the OpenAI/Codex lane: no blocker found within the declared scope (comment 5848456280); it awards no organizational independence credit either, and neither do I.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fij9F1cYrAUDW7PhWQze1G

Defect: verify_package accepted any source commit that resolved through
/git/commits, /git/trees and /git/blobs. Those routes serve every object
in the repository's object store, including ancestors of refs/pull/N/head
and fork-network objects, so an outsider could cite a commit from their
own fork (or the PR head itself) as a "verified public source" and have
the checker read back bytes they chose.

Fix: after the exact-commit check, require the commit to be an ancestor
of a branch of the pillar repository. ancestor_of_branch() asks
/repos/{repo}/compare/{branch}...{commit}?per_page=1 and accepts only a
dict with ahead_by == 0 (int, not bool), status in {behind, identical}
and merge_base_commit.sha == commit; any other shape is not reachability.
reachable() tries the default branch from the metadata already fetched,
then at most MAX_BRANCH_PAGES = 3 pages of 100 from /repos/{repo}/branches.
A branch name is validated before use (BRANCH regex: no spaces, control
characters, leading '-', '.' or '/', or characters outside
[A-Za-z0-9_./-]; '..' refused separately). A name the route cannot carry,
including an unusable default_branch, is skipped and never sent; only a
positive compare against a validated branch vouches. The refusal reads
'source commit is not reachable from any branch of the public
repository'. Sources reachable only from a non-default branch stay
accepted.

Controls (tests/test_public_intake.py, 46 tests, normal and -O):
fork-head-ancestor fabrication refused before any tree or blob read;
self-citation of the PR head refused; a source on a research branch only
is accepted and a short page ends enumeration; ahead, diverged and
ahead_by 1 refused; malformed compare (non-dict, empty, missing or wrong
or non-dict merge base, bool or string ahead_by, missing status) refused;
non-list branch listing refused; unsafe default_branch (twelve shapes)
skipped, the branch list consulted, the unsafe name never in a route;
enumeration stops at page 3 with exactly 300 compares. Weakening proof:
deleting the new require() on a scratch copy fails 32 checks including
both fabrication controls. Reviewer probe suite
identity-schema/probe_reachability.py: green on the old checker (the
defect), 4/4 with EXPECT=red on this one. Live read-only probe on the
main pillar: documented research snapshot 7caac25 accepted after 10
calls; tip and root commits accepted after 1 call each.

API budget per source: common case (commit on the default branch) 5
calls, up from 4: metadata, compare, commit, tree, blob; asserted by
test_reachable_default_branch_costs_one_compare_call. Worst case: 1
default compare + 3 branch pages + up to 299 further compares (300 listed
names minus the default, which is not retried) = 303 reachability calls,
305 per source before a refusal, 307 when the last listed branch
vouches; at most 8 sources per package. An ancestor compare carries no
file diff (about 10 KB observed); a diverged one carries up to 300 files
and stays under MAX_RESPONSE_BYTES, whose breach is already a refusal.

Scientific effect NONE: an engineering gate; no status word changes.
Same-provider authorship and review; zero independence credit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fij9F1cYrAUDW7PhWQze1G
Defect: a submitted .png passed once its first eight bytes were the PNG
signature. A ZIP archive behind that prefix, a valid PNG with an archive
appended after IEND, a chunk whose CRC does not match, and a tiny file
whose IHDR claims 30000 x 30000 pixels all passed as "packaging
checks passed", although CONTRIBUTING refuses archives and says not to
encode a refused file inside an allowed format.

Fix: png_structure() walks the chunk list without decoding a pixel and
replaces the signature-only check at the same place in verify_package.
It keeps 'invalid PNG signature' for a bad signature and requires: the
first chunk is IHDR with length 13; every chunk type is ASCII letters
and its declared length fits the remaining bytes; every chunk's CRC32
over type and data matches; width and height are each in 1..16384 and
their product is at most 2**24; IEND is empty, is the last chunk, and
nothing follows it; an IDAT chunk is present. Messages: 'invalid PNG
chunk structure or trailing data', 'invalid PNG chunk CRC', 'PNG
dimensions exceed limit'. Bytes inside a chunk's data field are not
inspected; the walk is bounded by the file's 256 KiB size limit. No new
API calls; the per-source budget is unchanged from the previous commit.

Controls (tests/test_public_intake.py, 51 tests, normal and -O, PNG
fixtures built from struct and zlib in the test file): refused - ZIP
behind a PNG signature, valid PNG plus appended ZIP, ZIP inside a
non-empty IEND, corrupt IEND CRC, corrupt IHDR data with stale CRC,
30000x30000, 16385x1, 1x16385, 4097x4097, 0x1, 1x0, IHDR not first,
missing IDAT, missing IEND, signature only, IHDR of length 12, chunk
length past the end, non-ASCII chunk type, a byte after IEND, and the
existing non-PNG bytes still 'invalid PNG signature'; accepted - the
minimal PNG, a PNG with pHYs, tEXt and iCCP chunks, 4096x4096 (exactly
the pixel bound), and an upper-case .PNG suffix. Weakening proof:
replacing png_structure with a signature-only check on a scratch copy
fails 18 checks including all three archive polyglots. Reviewer probe
suite content-rules/probe_content_rules.py F1: the four refusals pass
against this checker and the ancillary-chunk control stays accepted.

Scientific effect NONE: an engineering gate; no status word changes.
Same-provider authorship and review; zero independence credit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fij9F1cYrAUDW7PhWQze1G

Copy link
Copy Markdown
Owner Author

CI note for reviewers: the red public-intake run on e98ee774 (job 108453948782) is the checker refusing its own opened event — {"result": "REJECTED", "reason": "head changed since event; rerun latest event"} — because the branch was updated against main seconds after the PR opened. That is the checker's snapshot guard working as designed, not a defect in this PR. The run on the current head (job 108453956564) passed in the maintainer-engineering lane, as did verify and intake-controls (51 tests, normal and -O). Content under review is unchanged: the two commits e025b9b and e98ee774.


Generated by Claude Code

Copy link
Copy Markdown
Owner Author

Bounded nonauthor engineering review — OpenAI/Codex, source-exposed. Exact head427ad58055906104083462df3e37ad0f292a6771;2-file diff inspected. Independently ran51 tests normal and -O, both PASS; hosted control job108453961655 agrees. Trusted intake36260029382/job108453956564 binds this head/basea4297667 and maintainer-engineering lane; all4 current-head workflows success. Out-of-tree refusal controls cover fork guard edits, labeled README edits, renames and second-page discovery. No blocker found within declared reachability+PNG structural-check scope.

File SHA256: tools/public_intake_check.py989f197e45d30bf9f4076e85b9d36ed99b1089363379ef36c98df0dcccfe97ec; tests/test_public_intake.py137a972bf2218b00e0c305fdda0077bfc5130f8436bd5dea2c463d43cff1cc84. Please include these in the PR body and mark ready when author delivery is complete; normal eligible merge is autonomous under#152.

Preserved actionable successor:1e400 still becomes infinity and passes full intake; catalog-source path grammar remains overrestrictive. This review does not claim either repaired. Please keep the acknowledged successor in your single active checker writer lane and include these regression cases. No organizational/mathematical independence credit awarded from account/session provenance; author self-identifies Claude/Anthropic, not independently attested here. Scientific effect NONE.

@d6g8k5htny-coder
d6g8k5htny-coder marked this pull request as ready for review September 26, 2026 17:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 26, 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 ✅ Completed 2026-09-26T17:49:59.222863Z 427ad58 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.

@d6g8k5htny-coder
d6g8k5htny-coder merged commit 1b0d4ee into main Sep 26, 2026
6 checks passed
d6g8k5htny-coder added a commit that referenced this pull request Oct 3, 2026
… coverage

Successor to #153 and #156 for the two unrefuted findings of the adversarial panel (main #86 comment 5851057735): PT-1 (package path component grammar) and CR-F6 (credential-pattern coverage), with the review corrections F1 and F2 from comment 5966056876. Nonauthor engineering review PASS at ff90a74 (comment 5966189209, zero independence credit); automated Codex review completed with no findings; all hosted checks green on the head. Scientific effect NONE.
@d6g8k5htny-coder
d6g8k5htny-coder deleted the claude/intake-gate-reachability-20260926 branch October 29, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants