-
Notifications
You must be signed in to change notification settings - Fork 100
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
spike: uki image revocation and rollback #2429
Comments
SBAT was made for this I think: https://github.com/rhboot/shim/blob/main/SBAT.md |
by reading it looks like https://0pointer.de/blog/brave-new-trusted-boot-world.html took some inspiration from, at least looks like similarly a concept of an incremental counter is required. What is not clear is how that ties to the sealing process. From the Lennart's article he mention that when sealing against a TPM PCR Bank it is not only the PCR policy, but also the counter is used - which I'm afraid it will make it incompatible with the current installs (I also can't find a reference on systemd-* about that, so looks like something that can't be - yet - used?) |
Hello! I'm a bot, an experiment of @mudler and @jimmykarily. Thank you for opening this issue. It seems that your issue, titled "spike: uki image revocation and rollback" (#2429) in the "kairos" repository owned by "kairos-io", is not completely clear regarding the relationship with the sealing process and the compatibility with current installations. As you provided some additional context and potential alternatives like SBAT and the concept of using TPM counters, we can better understand the problem you're trying to address. However, more details are needed to meet the project's requirements. Please provide steps to reproduce (if it's a bug), and mention the versions of the relevant artifacts being used. Once you provide the necessary information, we will be able to classify your issue more accurately and assign the appropriate label. Thank you for your patience and understanding, and please remember that I'm just a bot. Best regards! |
@ci-robbot hello there, how do I get the sbat in python? |
Hello! I'm a bot, an experiment of @mudler and @jimmykarily. Thank you for the response. To get the
Remember that this solution is valid as of the current state of the artifacts. Make sure to specify the versions of the relevant artifacts in your issue as required by the project's guidelines. If you have any further questions or need more clarification, feel free to ask. Best regards! This conversation has been automatically audited by bot. The audit has identified that the information provided is sufficient to meet the project's requirements. Therefore, the issue can be labeled appropriately. The required details include a description of the issue, steps to reproduce (if it's a bug), and the versions of the relevant artifacts being used. Since the issue is clear and meets the requirements, I will assign the following labels to the issue: [question, triage]. |
sbat is only understood and used by the shim (https://uapi-group.org/specifications/specs/unified_kernel_image/#uki-components). We don't use the shim so we can't rely on sbat for revocation. |
2 things:
|
dbx revocation would be good enough I guess? But it means we need to generate the dbx or a way of updating the dbx (AFAIK you can update that one from userspace somehow?) so people can generate those from their own built efi files. What happens when you dont have access to those efi files anymore? How do you generate the hash for it?
Now it happens that v1 has a cve and you want to block it. You release Custom v4 with the dbx updated.
I mean, sounds good to me to use the actual mechanism in place in the firmware for this but it entails a bit of laying down the exact supported way of doing this. Im my machine I had updates to the dbx provided directyl from https://github.com/fwupd/fwupd (https://fwupd.org/) so maybe its possible to do this, ship the daemon and have the customers provide their own update server with dbx files? for other usecases (no internet) maybe just an upgrade to a new version is good enough. Or the fwupdate can be used to also update it via local files somehow? |
Yep, seems to be possible: https://github.com/fwupd/fwupd/tree/main/plugins/uefi-dbx
|
I think I have a preference for my second suggestion (keys rotation) which blacklists every past image by enrolling a new key. Keys can also be appended in dbx, which makes me wonder what happens if a key is both in db and dbx. I guess dbx wins and the key is rejected (?). Let us play a bit manually in qemu before we start bricking devices :D. |
First approach to use sbctl here: Foxboron/sbctl#296 |
Also suggested some preparation work here: Foxboron/sbctl#297 |
Tested without upgrade, just on a installed system and I seem to hit the same thing.
If I remove the Kairos2 key then it works again. There seems to be a connection between the Secureboot certs and the measurements somehow that we are not seeing. EDIT: This is on Ubuntu 24.04 |
Opened a ticket upstream on systemd to see if they can clarify systemd/systemd#32946 |
Updating here in case the other ticket goes nowhere. there is 2 ways of binding to a PCR when enrolling a luks partition/disk
Docs are kind fo confusing in here as they seem to be mutually exclusive, but are not. When we bind to the public-key-pcr 11, cryptenroll silently would also enroll to the PCR7, single measurement (Secureboot state and certs). The idea would be to set So it needs to be fixed upstream so we can skip binding to pcr7 automatically. There is a workaround for this, and its by skipping checking the tpm directly and using the tpm public SRK key to calculate the values. From systemd 255 and upwards, the tpm key is automaticaly extracted on boot and can be used to calculate the values to lock the luks device without ever going to the tpm directly by using This is now available in kcrypt v0.11.0 but it makes the minimum systemd version 255 (Ubuntu 24.04 and Fedora 40) and works perfectly. What does this means?
|
Talos has some utils to add and manage luks keys, maybe its possible to unlock and add a new key via that? |
CRYPTSETUP CAN ADD NEW KEYS!!!
That seems to use the tpm2 to update the keys, not asking for a password or anything!! So we could probably leverage that to sync a new tpm key if needed, even if its a manual action, we could do the following in the ugprade
And that may even work. Now if we were able to use the tpm token to update the same tpm token it would eb even better |
so an option would be to:
We need to give this a try. |
I guess for more sdecurity we could just unbind the encryption from 7 only and let 11 in there. So it will still cover the policy of the uki properly and onyl not bind to the secureboot PCR (which we already have a check in immucore) |
reminder: unbinds luks from tpm (I think). Update: cryptenroll can do that too: |
I created a script (attached) to automated the whole flow of revocation. I'm still doing something wrong though in the final steps (while re-binding the encryption to the new PCR values). The script should be run after the VM has booted into the ISO that we we are going to blacklist. I'm not sure if the final steps in which I run @Itxaka I don't quite get what you mean by
|
After enrolling new certs with
|
I created a new version of the script (below). It now un-binds pcr 7 before reboot to the upgraded system. The reboot succeeds but the final steps to re-bind pcr 7 fail with this error: https://github.com/systemd/systemd/blob/45af01d3111eb8d542d90f641913ee3c0db19719/src/cryptenroll/cryptenroll-tpm2.c#L361 The new version of the script:
|
@Itxaka suggests this is a bug in systemd. Using
In the end, the old images are not bootable anymore and the system boots successfully to the upgraded Kairos image (which is signed with the new keys). |
The above is a PoC that it's possible to revoke a cert (and possible an image hash following a similar procedure). It requires a reboot though, so automating this with suc-upgrade will be a tricky. Something must ensure that after reboot the additional steps will run. For now, we'll pause the work on this for a bit because with all the backporting for 3.0.x patch releases the state of master/main branches is a bit confusing (which kcrypt does kairos-agent and immucore use?). We can create a final script (or an e2e test, even better) and document the process after we bump everything to latest kcrypt. |
The important thing is that this process can happen remotely, not necessarily fully automated. The above PoC can work remotely so we are good. 2 things left for this ticket:\
|
To blacklist an image (instead of a cert), the same instructions work but when creating the from the booted kairos: $ hash-to-efi-sig-list /efi/EFI/kairos/active.efi active.esl and then from the workdir at the machine with the keys:
|
Is your feature request related to a problem? Please describe.
If a vulnerability is found in older images, we might want to disable the access to the encrypted portion of the disk for certain images. Similarly, if encryption keys are leaked, we would like to have a mechanism that allows or either to update the system to use a new key (by for instance using the old keys to update to new ones), or just invalidate the portion of the stack that is responsible to unencrypt the disk.
Describe the solution you'd like
A way to use old keys to generate an upgrade image that installs the new ones. Alternatively a mechanism that allows with an upgrade image to invalidate older images.
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: