Skip to content

ci: the Cachix signing key is available to code from same-repository pull requests #107

Open

Description

@ostermayer

Commit: 77bddab (master, 2026-10-18). File: .github/workflows/test.yml.

What I found

#71 narrowed the Cachix signing key to the two jobs that push, build_test_drivers and test_scenario. Both jobs still run repository code with the key in their environment: nix eval and nix build of the flake, and the scripts under test/ci/. A pull request from a branch in this repository runs with the secret. GitHub withholds secrets from fork and Dependabot pull requests, so the exposure is limited to people with write access, but it's there.

Someone with write access who opens a branch PR can read the key during the run, for example with builtins.getEnv "CACHIX_SIGNING_KEY" in flake.nix or a curl in test/ci/build.sh, and sign any store path for the bitcoinix cache. Users who substitute from the cache would then trust that path. That turns a write-access compromise into a binary cache compromise, which reaches every user, not only the repository.

Proposal

  • Keep pull request runs free of the key. Build and test as now, skip the push. build-to-cachix.sh and build_test_drivers.sh already do that when CACHIX_SIGNING_KEY is empty.
  • Sign and push only on the push to master event, after review and merge. The cache then holds only what master built.
  • Cost: a pull request that changes a test driver builds it on the runner instead of pulling it, and the first master run after merge pushes it. The driver build job took about 1 min 16 s with four drivers in my CI runs for ci: run the wireguard-lndconnect scenario #106, so that's small.

If you'd rather keep PR pushes for speed, a second cache with its own key for PR artifacts limits the damage to that cache.

I can send the PR if you want it.

Activity

  1. added
    area: ci
    status: needs decision
    type: security
    on Oct 23, 2026
  2. seberm commented on Oct 23, 2026

    @seberm
    Contributor

    Thanks for the write-up. The threat is real: anyone with write access can use repository secrets in a workflow run. Two corrections and a proposal.

    Impact. The bitcoinix cache isn't advertised to users. Neither the docs nor the flake (no nixConfig) tell anyone to add it as a substituter, so today its consumer is CI itself, plus anyone who added it on their own. The concrete harm is CI integrity: test/ci/build-to-cachix.sh treats an output that's already in the cache as "built successfully", so with the key someone can sign a fake vm-test-run-* path and get a green run without the tests running.

    Fix. Blanking CACHIX_SIGNING_KEY in test.yml for non-push events wouldn't be enough. A same-repository branch can change the workflow file itself, and repository secrets are available to runs from any branch. The key has to move into a GitHub environment whose deployment branch rule allows only master, with the repository secret deleted. The pushing jobs then use something like environment: ${{ github.event_name == 'push' && 'cachix' || '' }}, and PR runs build and test without pushing, as you describe.

    That still doesn't protect against a compromised maintainer account. To keep merging fast, we don't require approving reviews on master; only the release and signing paths need a code owner's review. So a maintainer account can get its own change onto master, where the key is available. Requiring approvals would close that, but it would slow down every merge, and with the current small team I don't think that trade-off is worth it. What the environment does stop is narrower credentials, such as a token that can push branches but can't merge or administer the repository, and any future collaborator with write access.

    Priority. Right now write access is limited to the maintainers and the cache only serves CI, so I'd postpone this. It becomes worth doing when either changes: more maintainers or developers get write access, or we start advertising the cache to users. At that point the environment change above is the way to go, and the extra PR build time you measured is acceptable.

    I'd skip the second cache for PR artifacts: it adds another key to manage and doesn't protect anything the environment wouldn't.

  3. added
    status: deferred
    and removed
    status: needs decision
    on Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cistatus: deferredtype: security

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions