Repository navigation
fix(security): guard pages-deploy against non-main workflow_dispatch (#87) - #88
Merged
Merged
Conversation
…87) workflow_dispatch had no branch filter, and the checkout step didn't pin a ref -- it used whatever ref triggered the run. The github-pages environment allowlists a gh-pages branch (confirmed via the environment API) that isn't protected by main's signature/PR rules and doesn't exist yet. Any collaborator with contents:write (no admin, no PR into main required) could create that branch with a malicious payload, dispatch this workflow against it, and publish to databoar.com.br unreviewed -- XSS, HubSpot form PII skim, defacement, or a rewritten wheelhouse PEP 503 index, with no trace on main. Two independent guards, so a bug in one doesn't reopen the hole: - Job-level `if: github.ref == 'refs/heads/main'` refuses to run at all unless the triggering ref is main. - Checkout now pins `ref: main` explicitly instead of following the triggering ref, so even a workflow run that did start checks out and deploys main's content regardless of what ref invoked it. Verified: YAML parses, zizmor (online, GH_TOKEN) reports 0 findings against the changed file. Closes #87
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
workflow_dispatchhad no branch filter, and the checkout step didn't pin a ref — it used whatever ref triggered the run. Thegithub-pagesenvironment allowlists agh-pagesbranch (confirmed via the environment API) that isn't protected bymain's signature/PR rules and doesn't exist yet. Any collaborator withcontents: write(no admin, no PR intomainrequired) could create that branch with a malicious payload, dispatch this workflow against it, and publish to databoar.com.br unreviewed — XSS, HubSpot form PII skim, defacement, or a rewritten wheelhouse PEP 503 index, with no trace onmain.Fix
Two independent guards, so a bug in one doesn't reopen the hole:
if: github.ref == 'refs/heads/main'— refuses to run at all unless the triggering ref ismain.ref: mainexplicitly instead of following the triggering ref, so even a run that did start checks out and deploysmain's content regardless of what ref invoked it.Test plan
python3 -c "import yaml; yaml.safe_load(...)")zizmoronline (GH_TOKEN=$(gh auth token) uvx zizmor .github/workflows/pages-deploy.yml) — 0 findingspush: maindeploy still works normally after merge (no behavior change on that path — same trigger, same checkout target)Closes #87