-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recipe for caching untrusted PRs? #49
Comments
Is this about caching all PRs or just specific ones? If you don't need to cache everything and can ask the user for a bit of setup,
That's exploitable, as soon as you run the builds from PRs, they can extract secrets (in this case cachix and all others). |
All PRs. Basically, everything the CI builds should be cached - both for speeding up CI rebuilds as well as instantaneous local builds when reviewing PRs.
Via which channel? edit: I guess fixed-output derivations with impureEnvVars might be a potential side channel? I would hope the secrets are not available in the daemon's environment, but that's a lot of assumptions, so perhaps the second approach is the way to go after all. |
You could use Environments to create two workflows with each own environment/secrets. Then each would use a different cache and in case the PR one gets abused, your main cache is still fine.
As long as your workflow only runs Nix it should be fine, but as soon as it runs an impure script it's easy to compromise it. |
Nice, that does sound like the easiest approach. Though I'll have to move the existing repo secrets to the new environment... |
As the readme rightly points out,
This begs the question: if one wanted to cache builds of PRs from arbitrary forks, what's the best way to do that? And what are caveats/security implications of doing so?
Off the top of my head, I can think of two approaches:
pull_request_target
trigger to build the PR via something likenix build .?rev=${{ github.event.pull_request.head.sha }}
(entirely untested), relying on hermetic evaluation to ensure that the PR code cannot access any secrets. This would fail if the build relies on scripts that are run outside of a Nix build, and the PR modified some of them.In either case, one might want to be mindful of the possibility of cache poisoning. I haven't seen too much discussion about this in the Nix community, but I would assume that Nix' hashing scheme is strong enough to make that a non-issue in practice. Still, concerned users might want to set up a separate cache for untrusted PRs and e.g. only activate it selectively on the cmdline (keeping in mind that the results of such a temporary build will, of course, remain in the local Nix store until they are GC'ed).
The text was updated successfully, but these errors were encountered: