-
Notifications
You must be signed in to change notification settings - Fork 48
[RFC] Proposal for Measured Boot Image/Rootfs #40
Comments
Nice proposal! First, we need to emphasize that block-based readonly protection scheme dm-verity is only the initial implementation for cc. In future, better approach such as filesystem-based protection will be involved. In dm-verity, hash device and data device can be separate or combined together. We'd better determine it now. In addition, people may care how dm-verity can defense the possible online/offline attacks to hash or/and data device, and which attacks cannot be protected in cc's use model. In other word, the info about attack vectors against cc is not described in details. |
Yes, I'll add this in the design part.
Agree, I'll add one section to discuss this part, I prefer to combine them together, but there still have two options for how to combine them together.
Yes, I'll add these to the threat vectos part. |
Thanks for the proposal @arronwy. I have a few comments and questions:
|
I read that as there are gaps with |
No, in our proposal, we don't sign the
Yes, the root hash is part of kernel cmdline and will be measured as attestation evidence.
Yes, I'll add the performance section, |
Current |
As long as the root hash is measured and compared with a reference value for it, we should be good. It would be good to describe that in the proposal. Another question: What's the kernel version requirement to support
+1
Yes, and that's a great proposal, thanks a lot. We just need to call it out, and make sure people with no |
Yes,thanks, I'll add these info.
Depends on the features,
Thanks, I'll add more detail info to the |
Let me clarify the details about how dm-verity provides the measurement and how it associates with attestation. I think @sameo and @arronwy have already reach out to this point. When guest fw is launching kernel, it will measure kernel command line. Assuming the command line contains the following content about dm-verity:
Then kernel boots up and then automatically run the integrated initramfs entrypoint script When launching the initial attestation, the related measurements in evidence including kernel command line with dm-verity root hash are collected and sent to attestation-service. In attestation-service side, the provenance of rootfs is retrieved from supply chain to RVPS which can generate the reference value to check against the root hash of rootfs embedded in kernel command line. dm-verity can defense the following attack vectors:
dm-verity cannot defense the following attack vectors:
So cc solution with dm-verity needs to protect against the possible attack which can tamper the hash blocks, data blocks and kernel commandline simultaneously. In addition, dm-verity mechanism cannot be bypassed/disabled through tampering kernel command line in cc solution. So providing cc_rootfs_verity parameters in cc kernel command line must be enforced. During runtime, the data blocks are always verified with hash blocks, and the verification results and layer 0 hash blocks are cached in memory. In addition, the hash tree walk only happens in the initial access to a data block. As time goes on, a memory threshold for dm subsystem may reach, leading to the cached layer 0 hash blocks are partially or completely released. At this time, the access to the data block that the corresponding hash block has been dropped will trigger a new hash tree walk. This design can explain why dm-verity can partially defense online tampering the hash blocks because the tampered hash block is not reloaded from disk unless the cached hash blocks are dropped. |
@jiazhang0 great insights, thanks!
You talked about the option for "workload provider would not like to deploy a protection boot image by self". Do you mean completely different image without If it's the former, then I think the "root_hash_sig_key_desc" approach would still work (the table signature verification would not be used when |
@mythi Let me clarify the background. "workload provider would not like to deploy a protection boot image by self" is a solution level affair. For example, a CSP provides the service for confidential container instance. In its instance configuration page, there is no option used to specify guest os image or upload a custom guest os image. In this case, CSP will provide and deploy the guest os image (and guest fw, kernel, initrd, kata-agent, attestation-agent and other artifacts deployed to Pod by CSP) for Pod (TEE). Is it trusted? No, it is just unverified. Need an attestation to give the result between trusted or untrusted. So in this case workload provider who deploys the container image would need the attestation to verify the root hash of the guest os image (of course other claims about various artifacts) deployed by CSP and then determine whether provisioning the secret to Pod. Alternately, a solution may allow workload provider to upload a custom guest os image. This image can be encrypted with dm-crypt or dm-integrity. Maybe dm-verity is not used in this solution. |
I understood this so that you for some reason wanted to keep the option to not use |
As an additional layer of ongoing protection, consider sending device-mapper measurements to the remote attestation service: |
Also keep an eye on LoadPin. https://listman.redhat.com/archives/dm-devel/2022-July/051520.html |
@arronwy, @jiazhang0, @jiangliu, great proposal and writeup! In past projects, we used a separate block device for the dm-verity hashtree. I think it's the more traditional approach for Linux dm-verity disk mount. |
Hi @bodzhang , yes, it will be easy to track hashtree as a seperate block device, I just submitted the PR: kata-containers/kata-containers#4967 to generate root hash as an separate partition for rootfs. Feel free to review or give feedbacks. |
@arronwy is this issue still relevant or can be closed? |
Hi @ariel-adam , this is still relevant and will be target in mid-November |
@arronwy What are the pending PRs for that feature? |
Hi @sameo These are the pending PRs: kata-containers/kata-containers#5136 kata-containers/kata-containers#5149 kata-containers/kata-containers#5169 This feature has no HW dependency, for operator, it only need decide whether to enable it by default and set the right config in kata |
I'm closing this one as we merged all pending PRs. |
Motivation
The CoCo stack utilize hardware-based TEE technology for runtime protection, and HWTEE will provide boot measurement feature to ensure the integrity of the runtime stack. The measured data will be used by attestation-agent as evidence to remote attestation service to verify the integrity of our CoCo runtime. Some key components like boot firmware, guest kernel, kernel cmdline are already included in the default measurement scope, but for guest boot image, this is the potential GAP, since it is big >100M and we need consider the boot performance and memory footprint during the measurement. Thanks @jiazhang0 @jiangliu , they give lots of valuable suggestions on this proposal.
Design
We may follow the measurement process like other components as below:
But as we described before, guest boot image is big, it's time consuming and take lots of memory for load and measurement, we proposal to utilize kernel integrity features to protect the integrity of boot image as below:
Kernel may support integrity protection feature at block level or filesystem level, we can allow the user to configure, for read only block device we can utilize
dm-verity
features to provide transparent integrity checking. In kernel cmdline, user can define below to enable integrity protection for the rootfs and this config will be measured as part of the kernel cmdline:Kernel only provided the integrity features, but still depends on the user space tools to do the setup and initialization work, we will package related tools and scripts into the initramfs and embedded into the kernel image with
CONFIG_INITRAMFS_SOURCE
config, then these user space tools and scripts will be measured together with the kernel image too.For initial implementation for CoCo, we will only implement the
dm-verity
scheme to provide the block-based readonly protection for the boot image. In future, another approach such as filesystem-based protection maybe involved.Introduction of
dm-verity
Device-mapper is infrastructure in the Linux kernel that provides a generic way to create virtual layers of block devices. Device-mapper verity target provides read-only transparent integrity checking of block devices using kernel crypto API.
dm-verity
uses a tree of sha256 hashes to verify blocks as they are read from a block device. This ensures files have not changed between reboots or during runtime. This is useful for monitoring the unauthorized changes to root. Verity devices are regular block devices which can be accessed in /dev/mapper.The device-mapper verity target device has two underlying devices, one is data device which used to store actual data, the other is hash device which used to store hash tree data will be used to verify the data integrity of data device.
(The picture is from: https://source.android.com/security/verifiedboot/dm-verity)
veritysetup
veritysetup
will generate adm-verity
hash tree during format operation, it can write the hash table to a file or block devices directly.Kata will pass the rootfs as one block device to the guest kernel like below:
To compatiable with current Kata API, we can add the hash tree to the boot image too, we have two options:
I did not try the method 2 yet, will give more info once tried.
Deploy solutions
Setup stage
Generate boot image
Using
veritysetup
tool to create data block and hash block and integrate into the boot imageGenerate
veritysetup
required kernel cmdline parametes(cc_rootfs_verity.scheme, cc_rootfs_verity.hash, ...)Generate initramfs with static build
veritysetup
andinit.sh
to setup thedm-verity
target deviceRuntime stage
Kernel boot initramfs
The init.sh in initramfs parse the kernel cmdline and setup the
dm-verity
target deviceMount the
dm-verity
target device as rootfs andswitch_root
to the init daemon in rootfsThis is the demo link:
https://asciinema.org/a/cSDgf2jeaRClmykjXNlPyVvPK
Devel Plan for CoCo
veritysetup
andinit.sh
to generate the initramfs imageReferences
https://www.kernel.org/doc/html/latest/admin-guide/device-mapper/verity.html
https://source.android.com/security/verifiedboot/dm-verity
https://wiki.gentoo.org/wiki/Custom_Initramfs
The text was updated successfully, but these errors were encountered: