-
Notifications
You must be signed in to change notification settings - Fork 59
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
create update process/solution for cosign key rotation #600
Comments
For option 2, We can add a simple tmpfiles.d to This can either be used to add the file if no other file exists, or overwrite an existing file depending on the behaviour we want. A tmpfiles that overwrites the existing policy would look something like this (would need to double check the file permissions):
So if we needed to have a script that uploads the new pub key to /etc, changes the policy and rebases, we can do so |
I edited the Ublue entry from our container policy to point to a new public key, updated to an impacted Bazzite image, deleted the container policy, and rebooted. The file was not restored in /etc, but copying it from /usr/etc back to /etc worked. Working on a script for this right now. Will only impact people using a custom policy.json outside of Ublue. People can stay on their signed image without a rebase. Will need to type in password to run with escalated privileges. No service needed and it's a one time thing |
This should do the trick: #!/usr/bin/bash
# Fetch new public key
curl https://raw.githubusercontent.com/ublue-os/bluefin/7964eae79dc188729ba2e890d3570d488a85b5c9/cosign.pub > /etc/pki/containers/ublue-os.pub
# Update key path
jq '.transports.docker."ghcr.io/ublue-os"[0].keyPath = "/etc/pki/containers/ublue-os.pub"' /etc/containers/policy.json > /etc/containers/policy.json
# Upgrade
rpm-ostree upgrade
# Restore policy
cp /usr/etc/containers/policy.json /etc/containers/policy.json |
@EyeCantCU Does the restore policy come after the reboot? |
The policy only needs to be changed during the upgrade. It can be ran all at once. We need to be sure we're using the new public key in config and have rebuilt the world with it so that that key gets used from then on |
#600 (comment) looks good. I would recommend having the container policy config point to keys in |
Slightly modified version of @EyeCantCU's script to solve a couple issues: #!/usr/bin/bash
set -eux
# Fetch new public key
curl https://raw.githubusercontent.com/ublue-os/main/main/cosign.pub > /etc/pki/containers/ublue-os.pub
# Update key path
jq '.transports.docker["ghcr.io/ublue-os"][0].keyPath = "/etc/pki/containers/ublue-os.pub"' /usr/etc/containers/policy.json > /etc/containers/policy.json
# Upgrade
rpm-ostree update
# Restore policy
cp /usr/etc/containers/policy.json /etc/containers/policy.json
cp /usr/etc/pki/containers/ublue-os.pub /etc/pki/containers/ublue-os.pub |
The policy file is user modifiable, it is not handled by rpm-ostree and is subject to drift. You cannot replace it with the default because users might have modified the file. Modifying /etc after an update is undefined behavior and can lead to undefined behavior if the update fails for some reason. Especially if the user is on an older version. I second @travier on using /etc for the policy file and I would rather that be the default from now on as well. Id skip the second part of the script and only download the key and run |
If the command "ghcr.io/ublue-os": [
{
"type": "sigstoreSigned",
"keyPath": "/etc/pki/containers/ublue-os-new.pub",
"signedIdentity": {
"type": "matchRepository"
}
}
], |
|
This will be enough for end users to run: #!/usr/bin/bash
set -eux
# Fetch new public key
curl https://raw.githubusercontent.com/ublue-os/main/main/cosign.pub > /etc/pki/containers/ublue-os.pub
# Update key path
jq '.transports.docker["ghcr.io/ublue-os"][0].keyPath = "/etc/pki/containers/ublue-os.pub"' /usr/etc/containers/policy.json > /etc/containers/policy.json
# Upgrade
rpm-ostree update If |
Maybe we should use an intermediary #!/usr/bin/bash
set -eux
# Fetch new public key
curl https://raw.githubusercontent.com/ublue-os/main/main/cosign.pub > /etc/pki/containers/ublue-os.pub
# Create temporary policy file for jq to read from
cp /etc/containers/policy.json /etc/containers/policy-bak.json
# Update key path
jq '.transports.docker["ghcr.io/ublue-os"][0].keyPath = "/etc/pki/containers/ublue-os.pub"' /etc/containers/policy-bak.json > /etc/containers/policy.json
# Clean up
rm -f /etc/containers/policy-bak.json
echo "Please reboot your system" |
It should already be running against the existing policy, unless there's something I'm missing? |
Sorry I should have listed the changes. I had to change the jq to read from |
Oh! I see what you mean. I didn't have this problem earlier but if you encountered it, we should use your workaround. Same end goal. Thank you! |
|
@EyeCantCU @p5 @antheas as a response to both your recent comments, here's my proposal: We'll create the following script in the
This accomplishes the goals which have already been addressed, and uses minimal number of commands, making it easier to document. Also, this is idempotent, and will not change a user's policy.json should they have modified it in a way which does not meet our assumptions. |
As a follow up... once we publish this, we can have a Discourse document with a TL;DR to just run |
We have added a redirect at https://fix.universal-blue.org to the script. That should be short enough for a user to wget or curl. |
Thanks ya'll, and again I apologize for this, thank you so much for mobilizing on behalf of the userbase. Oof. |
Very glad to see such measures taken after a mistake, it shows again a will to do things the right way 😄 |
With our solution for the surprise cosign key rotation completed, this is done. |
Given the urgent cosign key rotation which happened on the morning of July 2, 2024 (9:59AM EDT, specifically), we need a solution to handle upgrades since new images will not be signed with the key which is expected in our policy.
Pre-requisites for any solution:
Current proposed solutions:
The text was updated successfully, but these errors were encountered: