Skip to content

ci: pass the Cachix signing key only to the jobs that push - #71

Merged
seberm merged 1 commit into
bitcoinix:masterfrom
ostermayer:ci-cachix-key-scope
Oct 17, 2026
Merged

seberm merged 1 commit into
bitcoinix:masterfrom
ostermayer:ci-cachix-key-scope

Conversation

@ostermayer

@ostermayer ostermayer commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

test.yml sets CACHIX_SIGNING_KEY at workflow level. Every job gets it, including check_flake and release_tooling. Those jobs run repository scripts but never push to the cache. A script that runs in those jobs could sign and upload store paths that every bitcoinix user trusts.

Change

  • Pass CACHIX_SIGNING_KEY only to build_test_drivers and test_scenario. Their scripts call cachix push and cachix watch-exec.
  • Add permissions: contents: read at workflow level. No job in this file needs more.

Pull requests from forks never receive the secret. That doesn't change. The scripts already handle an empty key.

One side effect: test/nixos-search/ci-test.sh skips its optional flake-info cache upload in check_flake. It still builds and runs the test.

What this doesn't fix

Job scoping isn't a trust boundary against a contributor with push access to this repository. Such a contributor can edit test.yml in a pull request branch and read the key from the two build jobs. GitHub resolves that with a protected environment (key only in an environment that master can use) or by pushing to the cache only on master, not on pull requests. That's a repository settings change for the maintainers. This PR only narrows the exposure to the two jobs that need the key.

Testing

CI on this PR is the test. The two build jobs must still push to Cachix. The other jobs must still pass.

@seberm seberm added type: security Hardening or vulnerability (public-safe only) area: ci .github/, test/, dev/ labels Oct 17, 2026
@seberm

seberm commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Thanks, looks good. Since this comes from a fork, CI here runs without the secret, so we'll confirm on the first master run that the cache push still works.

A note for future PRs: if AI tooling helps with a change, AGENTS.md ("AI-assisted contributions") asks for an Assisted-by: commit trailer naming at least the tool and the primary model with its version. No need to change this PR for it.

`CACHIX_SIGNING_KEY` was set at workflow level, so every job had it,
including `check_flake` and `release_tooling`, which run repository
scripts but never push to the cache. Scope it to `build_test_drivers`
and `test_scenario`, the two jobs whose scripts call `cachix push` or
`cachix watch-exec`, and set the workflow's token permissions to
`contents: read`.
@seberm
seberm force-pushed the ci-cachix-key-scope branch from fb85a41 to 230b5e8 Compare October 17, 2026 22:53
@seberm

seberm commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Sorry, I rebased this branch onto master myself before merging, and that dropped your commit signature. I'm fine with that for this PR, so no need to do anything here.

For future PRs: are you OK with me rebasing your branches when they fall behind master, knowing it drops the signature on your commits? If yes, I'll rebase and merge without waiting for you. If not, that's fine too: I'll ask you to rebase and wait for your push before merging.

@seberm
seberm merged commit 62908c2 into bitcoinix:master Oct 17, 2026
6 checks passed
@ostermayer

Copy link
Copy Markdown
Collaborator Author

Yes, rebase my branches whenever they fall behind and merge without waiting. Losing the signature on the rebased commits is fine. Thanks for the note on the trailer. I'll add it to the open PRs you've asked on.

seberm added a commit that referenced this pull request Oct 25, 2026
test/nixos-search/ci-test.sh pushed its flake-info build to Cachix when
CACHIX_SIGNING_KEY was set. Since #71 scoped the key to build_test_drivers
and test_scenario, check_flake no longer has it, so nothing pushes
flake-info. The cached build stopped matching when #125 bumped the
nixos-search input, and since then every check_flake run builds flake-info
and a patched Nix from source, including Nix's test suites: 28-29 min
instead of about 1 min on master.

check_flake now builds flake-info in its own step and pushes it from a
separate step that runs only on pushes to master and is the only step that
gets the key. Both run before ci-test.sh, so flake-info, which ci-test.sh
runs outside the Nix build sandbox, runs only after the key step.
ci-test.sh no longer pushes.

Assisted-by: Claude Code (claude-opus-5-5)
msgilligan pushed a commit to msgilligan/bitcoinix that referenced this pull request Nov 8, 2026
test/nixos-search/ci-test.sh pushed its flake-info build to Cachix when
CACHIX_SIGNING_KEY was set. Since bitcoinix#71 scoped the key to build_test_drivers
and test_scenario, check_flake no longer has it, so nothing pushes
flake-info. The cached build stopped matching when bitcoinix#125 bumped the
nixos-search input, and since then every check_flake run builds flake-info
and a patched Nix from source, including Nix's test suites: 28-29 min
instead of about 1 min on master.

check_flake now builds flake-info in its own step and pushes it from a
separate step that runs only on pushes to master and is the only step that
gets the key. Both run before ci-test.sh, so flake-info, which ci-test.sh
runs outside the Nix build sandbox, runs only after the key step.
ci-test.sh no longer pushes.

Assisted-by: Claude Code (claude-opus-5-5)
@ostermayer
ostermayer deleted the ci-cachix-key-scope branch November 8, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci .github/, test/, dev/ type: security Hardening or vulnerability (public-safe only)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants