From cdf12f426277fcf6d71299fe3f567e55e51dae41 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 10:32:09 -0800 Subject: [PATCH 1/2] ci(pullfrog): keep the job token off disk and the runner user untrusted by Nix The installer trusted the runner user, so the agent could set daemon options such as post-build-hook that run as root. Install with no token and no runner trust, pass the token to the PATH step alone through NIX_CONFIG, and fail if it still reached /etc/nix or the receipt. This replaces scrubbing the token after the installer wrote it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pullfrog.yml | 23 ++++++++++++----------- quest/m0/pullfrog-setup.md | 6 ++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pullfrog.yml b/.github/workflows/pullfrog.yml index efea91c9..ad3eb05a 100644 --- a/.github/workflows/pullfrog.yml +++ b/.github/workflows/pullfrog.yml @@ -35,25 +35,26 @@ jobs: - uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # main with: determinate: false + # The agent's shell can reach the daemon and read /etc/nix and + # /nix/receipt.json: keep the job's token out of both, and keep the + # runner user untrusted, since a trusted user's settings, such as a + # post-build-hook, run as root. + github-token: "" + trust-runner-user: false - name: Put the dev shell's tools on PATH # bash, not the default shell, for pipefail: a failing print-dev-env # must fail the step, not write an empty PATH. shell: bash + env: + # Authenticated fetches of the flake's inputs, for this step only. + NIX_CONFIG: access-tokens = github.com=${{ github.token }} + TOKEN: ${{ github.token }} run: | nix print-dev-env --json | jq -r '.variables.PATH.value' | tr ':' '\n' | grep '^/nix/store/' | paste -sd: >>"$GITHUB_PATH" - # The installer wrote the job's token into world-readable nix.conf and - # nix.custom.conf, and into /nix/receipt.json's plan, where the agent's - # shell could read it. - - name: Remove the job token from Nix's config - env: - TOKEN: ${{ github.token }} - run: | - sudo find /etc/nix -type f -exec sed -i '/^access-tokens/d' {} + - sudo chmod 0600 /nix/receipt.json - if sudo grep -rqF "$TOKEN" /etc/nix; then - echo "the job token is still under /etc/nix" >&2 + if sudo grep -rqF "$TOKEN" /etc/nix /nix/receipt.json; then + echo "the job token reached Nix's config" >&2 exit 1 fi - name: Run agent diff --git a/quest/m0/pullfrog-setup.md b/quest/m0/pullfrog-setup.md index 2418a662..5273bfd0 100644 --- a/quest/m0/pullfrog-setup.md +++ b/quest/m0/pullfrog-setup.md @@ -20,8 +20,10 @@ so their `pullfrog.yml` gains steps before the agent under `Waiting`): install Nix, put the `/nix/store` entries of `main`'s `nix print-dev-env` `PATH` on `GITHUB_PATH` (Pullfrog's restricted shell keeps `PATH` but drops other dev-shell variables, so `nix develop --command` -stays the way to anything needing them), and delete the job token the -installer writes into `/etc/nix/nix.conf`, failing if it remains. The +stays the way to anything needing them), and keep the job's token and Nix +daemon trust from the agent: the installer gets no token and leaves the +runner user untrusted, the PATH step alone fetches with the token, and the +job fails if the token reached Nix's config. The `pullfrog` environment admits only `main`, so these steps always build the default branch's shell; `checkout_pr` moves to a PR's head only afterwards, and `quest context`, now on the agent's PATH, carries the rule against From a272645f425348dcce4e20c53c24eb63c2992511 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 11:41:32 -0800 Subject: [PATCH 2/2] ci(pullfrog): fail the setup if the Nix daemon trusts the runner user trust-runner-user: false only stops the installer adding the runner to trusted-users; assert the daemon really treats it as untrusted, as the token guard does for the token, since neither runs before merge. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pullfrog.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pullfrog.yml b/.github/workflows/pullfrog.yml index ad3eb05a..af2bab94 100644 --- a/.github/workflows/pullfrog.yml +++ b/.github/workflows/pullfrog.yml @@ -57,6 +57,10 @@ jobs: echo "the job token reached Nix's config" >&2 exit 1 fi + if ! nix store info --json | jq -e '.trusted == false or .trusted == 0' >/dev/null; then + echo "the Nix daemon trusts the runner user" >&2 + exit 1 + fi - name: Run agent uses: pullfrog/pullfrog@0741f79ecebfa4469a010644d2aed2d96d32d489 # v0.1.127 with: