Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/THREAT_MODEL.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,24 @@ An attacker who controls any of these already has what github-workflows could gi

## Untrusted inputs

| Input | Comes from | What github-workflows guarantees |
| ---------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Pull request files | Any contributor | Read by read-only jobs only; inputs reach shells through environment variables. |
| Artifacts from read-only jobs | Jobs that ran project code | The writer accepts only the changelog and fragment deletions, or the paths the caller's `allowed-paths` names, as regular files or deletions. |
| Files already on PyPI | A partial or earlier upload | Digests and attestations must match before the GitHub Release is published. |
| Repository hooks and LaTeX sources | The caller's repository, including pull requests | LaTeX and pre-commit hook code runs in jobs without a write token, except the mirror job, which refuses pull request and other untrusted caller events before it checks out the repository. |
| Input | Comes from | What github-workflows guarantees |
| ---------------------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| Pull request files | Any contributor | Read by read-only jobs only; inputs reach shells through environment variables. |
| Artifacts from read-only jobs | Jobs that ran project code | The writer accepts only the changelog and fragment deletions, or the paths the caller's `allowed-paths` names, as regular files or deletions. |
| Files already on PyPI | A partial or earlier upload | Digests and attestations must match before the GitHub Release is published. |
| Repository hooks and LaTeX sources | The caller's repository, including pull requests | LaTeX and pre-commit hook code runs in jobs without a write token, except the mirror job, which a fork's pull request runs with a read-only token. |

## Threats and controls

| STRIDE | Threat | Control |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Tampering | A compromised build job smuggles a workflow change into the release commit. | `validate-release-patch` path and mode allowlist. |
| Tampering | A maintenance patch from a job that ran project code changes a path or mode outside the caller's allowlist, or replaces a reviewed maintenance branch. | `open-maintenance-pr` checks paths and modes in a read-only job, then verifies the digest of that patch before minting the App token. Each run force-pushes only its own branch with a lease, and the pull request still needs review. |
| Elevation of privilege | PR code reads the release App token. | The token is minted only in the writer job, which runs no project code and refuses pull request and other untrusted caller events before it checks out the repository. |
| Elevation of privilege | PR code reads the release App token. | The token is minted only in the writer job, which runs no project code. |
| Tampering | A freshly published malicious tool version enters the release toolchain. | Hash-checked locks resolved with a seven-day upload cooldown, and the same cutoff for helper tools. |
| Repudiation | Release commits cannot be traced to an approved run. | Commits and tags are authored by the App from a recorded workflow run. |
| Tampering | A pull request replaces the Pages PDF or moves a published mirror tag. | The deploy job runs only on `main` and is the only job with write permission. The mirror compares a published tag's tree, refuses different content, and pushes without force. |
| Elevation of privilege | Pull request hook code runs with the mirror job's write token. | The mirror job refuses `pull_request`, `pull_request_target`, `workflow_run`, `issue_comment`, and `merge_group` callers before it checks out the repository, so hook code from a pull request never runs with its write token. |
| Elevation of privilege | Pull request hook code runs with the mirror job's write token. | A fork's pull request runs with a read-only token and no secrets; a caller adds another trigger only through a reviewed pull request. |

## Release chain

Expand Down Expand Up @@ -98,8 +98,8 @@ Callers pin the full commit SHA of a release.
## Accepted risks

- The build job runs the project's own build backend; its outputs, not its behavior, are verified.
- The mirror job runs the caller's pre-commit hooks while it holds `contents: write`. It refuses pull request and other
untrusted caller events, so hooks run only for pushes, schedules, dispatches and releases.
- The mirror job runs the caller's pre-commit hooks while it holds `contents: write`. It runs for whichever events its
caller workflow triggers on.

## Keeping this current

Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/github-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ jobs:
permissions:
contents: write
steps:
- name: 🚫 Refuse untrusted caller event
env:
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
pull_request | pull_request_target | workflow_run | issue_comment | merge_group)
echo "::error::writer job refuses $EVENT_NAME callers; call it from push, schedule, workflow_dispatch or release"
exit 1
;;
esac
- name: 📩 Download distributions
id: distributions
background: true
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/latex-to-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ jobs:
contents: write
pages: read
steps:
- name: 🚫 Refuse untrusted caller event
env:
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
pull_request | pull_request_target | workflow_run | issue_comment | merge_group)
echo "::error::writer job refuses $EVENT_NAME callers; call it from push, schedule, workflow_dispatch or release"
exit 1
;;
esac
- name: 📥 Check out repository
uses: actions/checkout@v7.0.1
with:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/open-maintenance-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,6 @@ jobs:
outputs:
number: ${{ steps.pull-request.outputs.number }}
steps:
- name: 🚫 Refuse untrusted caller event
env:
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
pull_request | pull_request_target | workflow_run | issue_comment | merge_group)
echo "::error::writer job refuses $EVENT_NAME callers; call it from push, schedule, workflow_dispatch or release"
exit 1
;;
esac
- name: 📥 Check out repository
uses: actions/checkout@v7.0.1
with:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/prepare-release-creator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,6 @@ jobs:
permissions:
contents: read
steps:
- name: 🚫 Refuse untrusted caller event
env:
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
pull_request | pull_request_target | workflow_run | issue_comment | merge_group)
echo "::error::writer job refuses $EVENT_NAME callers; call it from push, schedule, workflow_dispatch or release"
exit 1
;;
esac
- name: 📩 Download release patch
id: patch
background: true
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/prepare-towncrier-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,6 @@ jobs:
permissions:
contents: read
steps:
- name: 🚫 Refuse untrusted caller event
env:
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
pull_request | pull_request_target | workflow_run | issue_comment | merge_group)
echo "::error::writer job refuses $EVENT_NAME callers; call it from push, schedule, workflow_dispatch or release"
exit 1
;;
esac
- name: 📥 Check out repository
uses: actions/checkout@v7.0.1
with:
Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/publish-pre-commit-mirror.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ jobs:
permissions:
contents: write
steps:
- name: 🚫 Refuse untrusted caller event
env:
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
pull_request | pull_request_target | workflow_run | issue_comment | merge_group)
echo "::error::writer job refuses $EVENT_NAME callers; call it from push, schedule, workflow_dispatch or release"
exit 1
;;
esac
- name: 📥 Check out repository
uses: actions/checkout@v7.0.1
with:
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ the checks that guard its keys.
Two rules run through all of them:

- **Keys stay away from project code.** Jobs that run hooks, tests, or builds hold read-only tokens. A writer job gets
the App key or `contents: write`, checks the patch or artifact it was handed, and refuses `pull_request`,
`pull_request_target`, `workflow_run`, `issue_comment`, and `merge_group` triggers. Writer jobs run no project code,
except the pre-commit mirror, which runs the repository's hooks and refuses those triggers for that reason.
the App key or `contents: write`, and checks the patch or artifact it was handed. Writer jobs run no project code,
except the pre-commit mirror, which runs the repository's hooks.
- **Tools arrive cooled.** Release tools install hash-checked from the caller's `pylock.toml`; tools the Actions need
for themselves install from PyPI only once a release is seven days old, by default. See
[Locked tools and cutoffs](docs/locked-tools.md).
Expand Down
3 changes: 3 additions & 0 deletions changelog.d/+drop-diff-visible-guards.change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Writer jobs no longer refuse `pull_request`, `pull_request_target`, `workflow_run`, `issue_comment` and `merge_group`
callers, and `validate-news` no longer fails a pull request that deletes `pylock.toml` while Nab is configured; review
of the pull request covers both.
6 changes: 2 additions & 4 deletions docs/latex-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@ Input `root-file` (default `main.tex`): the root TeX file latexmk compiles. The

Setup: enable GitHub Pages for the `gh-pages` branch, and create a `release` environment that allows `main`.

Runs are grouped per ref; a newer run cancels an older one except on `main`. The `deploy` job refuses `pull_request`,
`pull_request_target`, `workflow_run`, `issue_comment`, and `merge_group` callers before it checks out the repository,
and it runs only when the ref is `main`, so the `pull_request` trigger in the example builds the PDF without deploying
it.
Runs are grouped per ref; a newer run cancels an older one except on `main`. The `deploy` job runs only when the ref is
`main`, so the `pull_request` trigger in the example builds the PDF without deploying it.
4 changes: 1 addition & 3 deletions docs/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ All three need the same setup:
`RELEASE_APP_CLIENT_ID` variable (a repository variable works too).
- The caller passes the secret by name. GitHub requires this mapping even when the key exists only in the writer job's
environment.
- Trigger the caller on `push`, `schedule`, `workflow_dispatch`, or `release`. The writer job refuses `pull_request`,
`pull_request_target`, `workflow_run`, `issue_comment`, and `merge_group` callers: its first step fails with an error
naming the event, before the checkout and before the App token exists.
- Trigger the caller on `push`, `schedule`, `workflow_dispatch`, or `release`.

## Refresh the release lock: `upgrade-release-tools.yaml`

Expand Down
3 changes: 1 addition & 2 deletions docs/pre-commit-mirror.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ Behaviour worth knowing:
moved tag changes the rev users have pinned; bump the package version to publish new content.
- On a ref other than `main` the workflow generates and commits locally but pushes nothing.
- The job runs the repository's hooks while it holds `contents: write`. Trigger it on pushes to `main`, schedules, and
manual dispatches. It refuses `pull_request`, `pull_request_target`, `workflow_run`, `issue_comment`, and
`merge_group` callers before it checks out the repository, so no pull request's hook code runs with that token.
manual dispatches.
3 changes: 0 additions & 3 deletions docs/release-prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ Behaviour shared by both workflows:
changelog, prek installs only that formatter's hook, under the seven-day cutoff, so a hook the release never runs
cannot fail it. It needs `contents: read` and `pull-requests: read` to resolve pull request authors.
- `push` checks out with `fetch-depth: 1`. Every job uses `persist-credentials: false`.
- `push` refuses `pull_request`, `pull_request_target`, `workflow_run`, `issue_comment`, and `merge_group` callers. Its
first step fails with an error naming the event, before the patch is downloaded and before the App token exists.
Trigger the caller on `push`, `schedule`, `workflow_dispatch`, or `release`.
- One dispatch prepares one tag; run separate dispatches for separate packages. Put repository-specific checks in a
preceding caller job and make the prepare job depend on it.
- The caller passes `RELEASE_APP_PRIVATE_KEY` by name; the client ID comes from the `release-auth` environment's
Expand Down
4 changes: 0 additions & 4 deletions docs/release-publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,6 @@ with title `<title-prefix><tag>`. Run it after the PyPI job. The `release` envir
| `exclude-newer` | `7 days` | Cutoff for `pypi-attestations`. |
| `exclude-newer-package` | empty | Newline-separated `name=date` overrides. |

The job refuses `pull_request`, `pull_request_target`, `workflow_run`, `issue_comment`, and `merge_group` callers: its
first step fails with an error naming the event, before any artifact is downloaded or the Release is written. Trigger
the caller on `push`, `schedule`, `workflow_dispatch`, or `release`.

## Building-block Actions

### `render-release-notes`
Expand Down
12 changes: 0 additions & 12 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@ Errors the shared workflows and Actions report, keyed by the text in the job log

## Any writer job

**`writer job refuses pull_request callers; call it from push, schedule, workflow_dispatch or release`**

A job that holds the App key or `contents: write` was called from an event that can run untrusted code: `pull_request`,
`pull_request_target`, `workflow_run`, `issue_comment`, or `merge_group`. Trigger the caller workflow on `push`,
`schedule`, `workflow_dispatch`, or `release`. For a release rehearsal on pull requests, pass `dry-run: true`, which
skips the writer job; see [Dry run on pull requests](release-prepare.md#dry-run-on-pull-requests).

**A dispatched check workflow prepared a real release.** The dry-run input was derived from `github.event_name`. A
called workflow sees its caller's event, so derive nothing: pass `dry-run: true` from the gate workflow.

Expand All @@ -30,11 +23,6 @@ cancels its runs.

An `allow-skipped` entry of `required-checks` is not a job ID in the gate's `needs`. Fix the typo; the message names it.

**`the release lock was removed`**

The pull request deletes `pylock.toml` while `[tool.nab]`, `nab.toml`, or `additional-lock` still configures Nab.
Restore the lock, or remove the Nab configuration in the same pull request.

## Locks and cutoffs

**`... uploaded-prior-to exception expired on <date>; remove it or extend its expiry`**
Expand Down
1 change: 0 additions & 1 deletion tests/publish_pre_commit_mirror/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def workflow() -> JsonObject:

def test_steps_run_in_order(workflow: JsonObject) -> None:
assert [item["name"] for item in steps(workflow, "mirror")] == [
"🚫 Refuse untrusted caller event",
"📥 Check out repository",
"📦 Install uv",
"⚙️ Configure Git identity",
Expand Down
1 change: 0 additions & 1 deletion tests/release_workflow/test_github_release_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def test_github_release_verifies_pypi_before_publishing(workflow: JsonObject) ->
names = [item["name"] for item in steps(workflow, "github-release")]

assert names == [
"🚫 Refuse untrusted caller event",
"📩 Download distributions",
"📩 Download release notes",
"🐍 Install uv and Python",
Expand Down
Loading