From 29d89bc1ef927316e2a9134db57b9414d78ae4fe Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 10:08:19 -0800 Subject: [PATCH 1/4] ci(pullfrog): give reviews the dev shell's tools Co-Authored-By: Claude Opus 5.5 --- .github/workflows/pullfrog.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/pullfrog.yml b/.github/workflows/pullfrog.yml index 5d516c9cb..0ddfcf9fc 100644 --- a/.github/workflows/pullfrog.yml +++ b/.github/workflows/pullfrog.yml @@ -29,6 +29,26 @@ jobs: with: fetch-depth: 1 persist-credentials: false + # Edited: what the review needs to run the repository's checks and + # tests. The environment admits only main, so the dev shell comes from + # the default branch, not a pull request's head. + - uses: ./.github/actions/nix + - name: Put the dev shell's tools on PATH + 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, + # where the agent's shell could read it. + - name: Remove the job token from Nix's config + env: + TOKEN: ${{ github.token }} + run: | + sudo sed -i '/^access-tokens/d' /etc/nix/nix.conf + if sudo grep -rqF "$TOKEN" /etc/nix; then + echo "the job token is still under /etc/nix" >&2 + exit 1 + fi - name: Run agent uses: pullfrog/pullfrog@0741f79ecebfa4469a010644d2aed2d96d32d489 # v0.1.127 with: From 03088803df3cb3a8e83a6e1ad982b343e2ab3432 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 10:16:27 -0800 Subject: [PATCH 2/4] ci(pullfrog): fail on a failed print-dev-env, scrub the token from nix.custom.conf and the receipt Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/pullfrog.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pullfrog.yml b/.github/workflows/pullfrog.yml index 0ddfcf9fc..2881333d3 100644 --- a/.github/workflows/pullfrog.yml +++ b/.github/workflows/pullfrog.yml @@ -34,17 +34,22 @@ jobs: # the default branch, not a pull request's head. - uses: ./.github/actions/nix - 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 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, - # where the agent's shell could read it. + # 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 sed -i '/^access-tokens/d' /etc/nix/nix.conf + 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 exit 1 From 702800f8a7d5abfbec339d1be267c4a478c36bba Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 10:32:09 -0800 Subject: [PATCH 3/4] 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 | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pullfrog.yml b/.github/workflows/pullfrog.yml index 2881333d3..ad3eb05ac 100644 --- a/.github/workflows/pullfrog.yml +++ b/.github/workflows/pullfrog.yml @@ -32,26 +32,29 @@ jobs: # Edited: what the review needs to run the repository's checks and # tests. The environment admits only main, so the dev shell comes from # the default branch, not a pull request's head. - - uses: ./.github/actions/nix + - 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 From 5ffd0c1902a2c513d7175351b902eb57c2afa559 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 11:41:32 -0800 Subject: [PATCH 4/4] 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 ad3eb05ac..af2bab94a 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: