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

ignore initramfs from bootloader #2729

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Jan 10, 2023

Issue number:

#2501

Description of changes:
For Secure Boot support, the GRUB configuration (grub.cfg) will need to be signed by a trusted key, so that the chain of trust extends to the kernel command line, which contains sensitive data such as the dm-verity root hash.

However, Bottlerocket also allows the boot config feature to be used to extend the kernel command line. Boot config data is passed by the bootloader using the "initrd" mechanism; it consists of a payload at the end of the initramfs cpio buffer list.

In normal use, the "initrd" file should only ever contain boot config data. However, because this file is locally generated, it cannot be signed by a key known to the chain of trust. Because it is treated as an initramfs, it could be leveraged to run an unverified userspace by prepending it with an actual initramfs.

This change causes the kernel to discard any initramfs or initrd data passed by the bootloader. Any boot config data remaining at the end of the input will still be processed, as intended.

Without Secure Boot support, ignoring the initramfs is not useful as a security measure, but it still improves robustness by preventing accidental usage that might lead to boot failures.

Testing done:
Tested on variants with a 5.10 (aws-k8s-1.23) and a 5.15 (aws-k8s-1.24) kernel.

As expected, dmesg no longer shows the "Trying to unpack rootfs image as initramfs..." message, and bootconfig data is still processed.

[fedora@admin]$ sudo dmesg|grep Unpack
[fedora@admin]$ sudo sheltie
bash-5.1# cat /proc/bootconfig 
kernel.foobar = "baz"

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

For Secure Boot support, the GRUB configuration (grub.cfg) will need
to be signed by a trusted key, so that the chain of trust extends to
the kernel command line, which contains sensitive data such as the
dm-verity root hash.

However, Bottlerocket also allows the boot config feature to be used
to extend the kernel command line. Boot config data is passed by the
bootloader using the "initrd" mechanism; it consists of a payload at
the end of the initramfs cpio buffer list.

In normal use, the "initrd" file should only ever contain boot config
data. However, because this file is locally generated, it cannot be
signed by a key known to the chain of trust. Because it is treated as
an initramfs, it could be leveraged to run an unverified userspace by
prepending it with an actual initramfs.

This change causes the kernel to discard any initramfs or initrd data
passed by the bootloader. Any boot config data remaining at the end
of the input will still be processed, as intended.

Without Secure Boot support, ignoring the initramfs is not useful as
a security measure, but it still improves robustness by preventing
accidental usage that might lead to boot failures.

Signed-off-by: Ben Cressey <[email protected]>
@bcressey bcressey merged commit dcf3fce into bottlerocket-os:develop Jan 12, 2023
@bcressey bcressey deleted the ignore-initramfs branch January 12, 2023 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants