Skip to content
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

nix copy --to s3:// will copy unsigned paths to binary cache even if --no-check-sigs isn't used #12491

Open
2 tasks
arianvp opened this issue Feb 17, 2025 · 3 comments
Labels
bug new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store

Comments

@arianvp
Copy link
Member

arianvp commented Feb 17, 2025

Describe the bug

nix copy --to s3:// seems to happily copy unsigned paths to a bucket. Which is very frustrating as that does not align with the docs of nix copy

Especially when you accidentally mis-type secret-key param. I did:

nix copy --to 's3://my-bucket?secret-key-file=my-secret-key-file' $(nix-build)

but secret-key-file should've been secret-key. Instead of failing to upload an unsigned path; nix copy silently copied over an unsigned path!

Steps To Reproduce

$ out=$(nix-build)
$ nix copy --to s3://my-bucket $out

Expected behavior

Nix should refuse copying unsigned store paths to an S3 bucket as --no-check-sigs has not been passed.

Metadata

Additional context

ref<const ValidPathInfo> BinaryCacheStore::addToStoreCommon(
seems to completely ignore the checkSigs argument passed to the function? We should probably check something here

Checklist


Add 👍 to issues you find important.

@arianvp arianvp added the bug label Feb 17, 2025
@arianvp
Copy link
Member Author

arianvp commented Feb 17, 2025

For example, copying the same to a local chroot store does fail:

$ nix copy --to ./store $(nix-build)
error: cannot add path '/nix/store/f2zx202h8skav3zaq7ajrg5bnm1q54sq-hello' because it lacks a signature by a trusted key

Copying to a local binary cache has the same bug:

$ nix copy --to file:///tmp/store $(nix-build)

silently succeeds.

So the bug seems to be in binary-cache-store.cc

@arianvp
Copy link
Member Author

arianvp commented Feb 17, 2025

Even more frustratingly; once you've copied; nix copy doesn't overwrite the narinfo file anymore.

So you can't just rerun nix store sign $out && nix copy --to s3:// out

Instead you have to do nix store sign --store s3 $out

@roberth roberth added new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store labels Feb 18, 2025
@roberth roberth added this to Nix team Feb 18, 2025
@github-project-automation github-project-automation bot moved this to To triage in Nix team Feb 18, 2025
@arianvp
Copy link
Member Author

arianvp commented Feb 19, 2025

it's also very hard to recover from accidentally pushing unsigned paths as .narinfo content is cached by nix client-side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store
Projects
Status: To triage
Development

No branches or pull requests

2 participants