Repository navigation
fix(ci): require trusted runner-policy owner evidence - #95
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_89211f2e-8657-484f-8505-55e97340f266) |
|
Claude finished @kyle-sexton's task in 1m 43s —— View job PR Review: fix(ci): require trusted runner-policy owner evidence
SummaryThis PR closes a real authorization-bypass vulnerability: before the fix, a repository could self-declare Logic change —
|
| Scenario | Before | After |
|---|---|---|
Config declares owner, no GITHUB_REPOSITORY |
✅ passes (bug) | ❌ 1 selector-pin finding |
Config declares owner + matching GITHUB_REPOSITORY |
✅ passes | ✅ passes |
Config declares owner + mismatched GITHUB_REPOSITORY |
❌ 1 finding | ❌ 1 finding |
Config omits owner + valid GITHUB_REPOSITORY |
❌ 1 finding (was "evidence unavailable") | ✅ passes |
The rename of the ownerlessRoot sub-case is particularly important: a repo without a config repositoryOwner can now successfully claim an external identity via GITHUB_REPOSITORY. This is intentional and the test confirms it.
One minor observation: the test checks for the exact selector-pin rule on the self-declared case, but verifies the message only via a regex (/owner-scoped.*owner evidence is unavailable/). That ties it to the selectorStatus message at runner-policy.mjs:922, which still uses policy.repositoryOwner (now undefined) to select the message. This is correct — the message "trustworthy repository owner evidence is unavailable" fires as expected.
No coverage gaps found.
Documentation
README changes accurately characterize the new contract:
repositoryOwneris "inventory and a mismatch tripwire only; it never authorizes" — correct.- Local run instructions now include
GITHUB_REPOSITORY=owner/repository— necessary and correct. - PowerShell equivalent is a nice addition for Windows contributors.
- The
distribution/README.mdclarification thatGITHUB_REPOSITORYis the trusted source aligns with what GitHub Actions provides by default.
Verdict
Approve. The fix is correct, the tests are comprehensive, and the documentation is accurate. No bugs, no regressions, no missing cases.
There was a problem hiding this comment.
Risk: medium. Not approving: Cursor Bugbot skipped (usage limit reached) and did not produce a clean automated review signal. Human review is needed before merge; no reviewers were assigned because no eligible non-author reviewers are available in this repository.
Sent by Cursor Approval Agent: Pull Request Router and Approver
…publish (#723) Closes #707 ## Summary The pages Worker (melodic-software/provisioning#705) scans a normalized copy of every upload, but `pages-publish` scanned only the raw bytes. Its early check therefore missed HTML-escaped, tag-split and JSON-escaped credential, path and hostname shapes. The client now scans decoded copies too, so it refuses an upload, or forces it private, before sending. The Worker remains the enforcing layer. ## Fix - `components/cloud-environment/pages-publish` builds two decoded copies in linear POSIX-awk passes, with no new dependency: - **Host copy**: exactly the Worker's `normalize()`. Tags are stripped. `&#NN;`, `&#xHH;`, amp, lt, gt, quot, apos and nbsp are decoded only when the `;` is present. `\\` becomes `\`. A credential found here exits 4, the same page the Worker would refuse with a 422. - **Wide copy**: adds the extra named entities, numeric entities without their `;`, and JS escapes (`\/`, `\"`, `\uXXXX`, `\u{…}`, `\xHH`). A credential found only here forces the page private instead of refusing it. - An invalid decoded code point (NUL, above U+10FFFF, or overlong) becomes U+FFFD, so it never joins two fragments into a token shape. - Machine-path and hostname shapes only ever force private, on the raw copy and both decoded copies. gitleaks, when present, runs on the raw page. - Path shapes are reconciled with `components/path-detection/machine-path-patterns.sh`: - `setup.sh` installs the script as a single file, so the five `HPP_*` bodies are copied in word for word, and a test fails if the copy and the library differ. - On decoded copies they add home paths with no trailing slash, the forward-slash and 8.3 Windows forms, and Windows checkout roots. - The cloud-environment README documents the decoded scan and a **Rollout of the decoded scan** paragraph (lifecycle exception for a check that blocks from day one, with the Worker evidence below). The path-detection README names the embedded copy. ## Verification - `bash components/cloud-environment/pages-publish.test.sh`: 233 assertions pass. - The escaped-form, HPP-only-shape, invalid-code-point and sync tests all fail against the old script. - Tests pin which escaped forms are refused and which go private. - An escaped placeholder and stray entities stay public. - A 2 MiB single line of each separator scans in under 20 s. - The Worker's own `scan()` (provisioning main `0809074`) was run over the samples. - It flags the entity, hex-entity and tag-split token forms. The client refuses those. - It flags nothing for the `_`, `\"`, `_` and `_`-without-`;` forms. The client forces those private. - `machine-path-patterns.test.sh` and `setup.test.sh` pass. shellcheck, `shfmt -i 2 -ci -d` and markdownlint-cli2 are clean. The ci-workflows `check-machine-specific-paths.sh` driver reports nothing. - Follow-ups left out of scope: - the Worker's "fleet hostname" and `CLOUDFLARE|CF_API_TOKEN` shapes, which the client lacks; - a pre-existing `pgup_` length mismatch (client 16+, Worker 20+). ## Related - melodic-software/provisioning#705 (the Worker's normalized scan, `cloudflare/pages-worker/src/scan.js`) - `components/path-detection/machine-path-patterns.sh` - #717 (vault-exec `-q`, same component) 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01G3BsUv4VeQ81gAPhk73xvs --------- Co-authored-by: Claude Opus 5.5 <[email protected]>


Summary
GITHUB_REPOSITORYidentity before applying owner-scoped selector-pin approvalsrepositoryOwneras inventory and a mismatch tripwire, never as authorization evidenceRoot cause
When
GITHUB_REPOSITORYwas absent, the analyzer trusted the audited policy file's ownrepositoryOwner. A repository could therefore self-declare an approved owner and unlockapprovedSelectorReferencesByRepositoryOwner.Impact
GitHub Actions continues to work through its default
GITHUB_REPOSITORYenvironment. Local callers must now provide trusted repository identity explicitly; a configured owner can only corroborate or reject that identity.Validation
Note
High Risk
Changes authorization for owner-scoped selector approvals in the CI policy gate; incorrect rollout could block legitimate owner-scoped pins locally or in CI, though the change tightens trust boundaries rather than relaxing them.
Overview
Closes a fail-open path where missing
GITHUB_REPOSITORYlet the analyzer treat.github/runner-policy.json#repositoryOwneras proof of identity, so a repo could self-declare an approved owner and unlockapprovedSelectorReferencesByRepositoryOwner.resolveRepositoryOwnernow returns no owner unless caller-suppliedGITHUB_REPOSITORYis present and valid; checked-inrepositoryOwneronly corroborates or rejects that external evidence (mismatch still fails closed). Owner-scoped selector pins therefore require trustworthy identity—typically GitHub Actions’ defaultGITHUB_REPOSITORYin CI.Docs require explicit
GITHUB_REPOSITORYfor local runs (shell/PowerShell examples). Tests cover missing identity, matching/mismatched owners, and ownerless config with external evidence. Globally approved selectors are unchanged.Reviewed by Cursor Bugbot for commit 50e97d0. Bugbot is set up for automated code reviews on this repo. Configure here.