-
Notifications
You must be signed in to change notification settings - Fork 0
security(deploy-pages): enforce explicit caller contract #1272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seonghobae
wants to merge
5
commits into
main
Choose a base branch
from
codex/pr901-current-main-replacement-20260824
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8a0a781
security(deploy-pages): enforce explicit caller contract
seonghobae c2e733f
Merge remote-tracking branch 'origin/main' into HEAD
seonghobae 55114c3
docs(pages): document canonical build paths
seonghobae 18bb273
Merge branch 'main' into codex/pr901-current-main-replacement-20260824
opencode-agent[bot] b544d9c
Merge branch 'main' into codex/pr901-current-main-replacement-20260824
opencode-agent[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # Cloudflare Pages reusable-workflow secret and input contract | ||
|
|
||
| ## Decision | ||
|
|
||
| The reusable Pages deployment declares and references exactly two required | ||
| secret names for compliant callers: `CLOUDFLARE_API_TOKEN` and | ||
| `CLOUDFLARE_ACCOUNT_ID`. Approved CWL callers MUST map them explicitly and | ||
| MUST NOT use `secrets: inherit`: | ||
|
|
||
| ```yaml | ||
| jobs: | ||
| deploy: | ||
| uses: ContextualWisdomLab/.github/.github/workflows/deploy-pages.yml@main | ||
| with: | ||
| project_name: example-marketing | ||
| build_dir: ./public | ||
| secrets: | ||
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
| ``` | ||
|
|
||
| This is an explicit named interface and caller policy, not a GitHub runtime | ||
| allowlist. GitHub allows a same-organization or same-enterprise caller to use | ||
| `secrets: inherit`; secrets inherited that way can be referenced by the called | ||
| workflow even when they are not declared under `on.workflow_call.secrets`. | ||
| The declaration documents and validates explicit named mappings but cannot | ||
| disable GitHub's inheritance keyword. The called workflow itself references | ||
| only the two Cloudflare names above. | ||
|
|
||
| The workflow keeps `contents: read`, checks out the caller repository, and uses | ||
| the token only for Pages deployment and optional domain attachment. For an | ||
| approved explicit-mapping caller, GitHub rejects an invocation that omits either | ||
| required name before the job starts; the runtime guard remains a value-free | ||
| defense-in-depth check. | ||
|
|
||
| ## Untrusted deployment inputs | ||
|
|
||
| Reusable-workflow string inputs are caller-controlled data. They are not | ||
| command, filesystem, Cloudflare-resource, or URL authority merely because the | ||
| caller is allowed to invoke the workflow. The workflow therefore validates the | ||
| three deployment inputs before any of them reaches Wrangler, a Cloudflare API | ||
| URL, or a shell-rendered summary. | ||
|
|
||
| `project_name` follows Cloudflare Pages' service boundary: one to 58 lowercase | ||
| alphanumeric/hyphen characters with an alphanumeric first and last character. | ||
| `build_dir` is bounded to a relative POSIX-style path, may not contain | ||
| option-like, traversal, whitespace, control, or backslash syntax, must resolve | ||
| to an existing directory, and must remain inside the exact checked-out | ||
| `GITHUB_WORKSPACE` after symlink resolution. | ||
| Every path component must be non-empty; callers should pass `./public`, not | ||
| `./public/`. | ||
| `custom_domain` is optional; when present it is bounded to DNS-style labels, | ||
| rejects path/query/fragment/port-like syntax, and is canonicalized to lowercase. | ||
| Invalid input fails with one generic value-free error rather than reflecting the | ||
| untrusted value. | ||
|
|
||
| Only the validator's sealed step outputs reach the Wrangler command, custom | ||
| domain API path, and job summary. The job display name is static so a raw | ||
| caller-supplied project name is not promoted into workflow presentation before | ||
| validation. The summary passes validated outputs through environment variables | ||
| rather than embedding raw GitHub expression text into the shell program. | ||
|
|
||
| Cloudflare's current Direct Upload documentation defines Pages deployment as | ||
| uploading one prebuilt asset directory with `wrangler pages deploy`, and its CI | ||
| guide uses the directory plus `--project-name=<PROJECT_NAME>`. This workflow | ||
| keeps exactly that product boundary while adding a stricter central validation | ||
| layer before argument construction. The validator is intentionally more | ||
| restrictive than accepting arbitrary strings: callers requiring a genuinely new | ||
| identifier/path shape must change the reviewed contract and its negative tests, | ||
| not bypass validation locally. | ||
|
|
||
| ## Migration and acceptance | ||
|
|
||
| As of 2026-08-24, a live organization code search found no product workflow | ||
| that calls this reusable workflow; only the central workflow and its README | ||
| examples referenced `deploy-pages.yml@...`. The root README, infrastructure | ||
| guide, workflow example, and this record now use the same explicit mapping, and | ||
| the permanent contract test scans every fenced YAML example. Re-run the | ||
| organization search before merge. Any consumer found later must add the two | ||
| explicit mappings in its thin caller under that repository's writer lease. | ||
| Treat any `secrets: inherit` caller as a leaf migration defect, not a reason to | ||
| broaden the central interface. | ||
|
|
||
| Acceptance requires workflow contract tests, syntax and supply-chain checks, | ||
| and realistic positive/negative input tests that execute the production | ||
| validator itself. At minimum the tests cover a normal project/build/domain, | ||
| argument-like project names, absolute/traversing/build-option paths, malformed | ||
| hostnames, and a symlink escaping the checkout. A protected-main caller canary | ||
| must prove that validated inputs reach Wrangler with both required secret | ||
| mappings. A missing-mapping negative control must stop before deployment and | ||
| must not print a credential. | ||
|
|
||
| ## Failure and rollback | ||
|
|
||
| If a consumer cannot migrate immediately, pin it to the last reviewed workflow | ||
| revision while its caller is repaired. Do not broaden the new interface, | ||
| reintroduce blanket inheritance, or interpolate raw inputs as a compatibility | ||
| shortcut. Roll back the central contract only for a confirmed GitHub reusable- | ||
| workflow or Cloudflare platform defect, and preserve the explicit two-name | ||
| secret interface plus fail-closed input validation in the replacement | ||
| transport. | ||
|
|
||
| If validation rejects a previously accepted caller, first determine whether the | ||
| caller relied on a genuinely supported Cloudflare identifier/path shape or on | ||
| ambiguous input that should never have crossed the command/URL boundary. Extend | ||
| the validator only with a focused RED/GREEN contract and keep symlink escape, | ||
| traversal, option injection, and value-free diagnostics intact. | ||
|
|
||
| ## APA 7th references | ||
|
|
||
| Cloudflare. (2026a, April 21). *Direct Upload*. Cloudflare Pages documentation. | ||
| https://developers.cloudflare.com/pages/get-started/direct-upload/ | ||
|
|
||
| Cloudflare. (2026b, April 21). *Use Direct Upload with continuous integration*. | ||
| Cloudflare Pages documentation. | ||
| https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/ | ||
|
|
||
| GitHub. (n.d.). *Reuse workflows*. GitHub Docs. Retrieved August 24, 2026, from | ||
| https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows | ||
|
|
||
| IgorMinar. (2023, May 16). *C3 project name input is not correctly validated* | ||
| [GitHub issue]. Cloudflare Workers SDK. | ||
| https://github.com/cloudflare/workers-sdk/issues/3222 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.