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

Exclude bootstrap-seeds from kernel bootstrap images #439

Merged
merged 1 commit into from
Feb 14, 2024

Conversation

Googulator
Copy link
Collaborator

In kernel bootstrap mode, the kernel (builder-hex0) includes the ability to assemble hex0 source code, and to execute basic commands, obviating the need for the bootstrap-seeds subdirectory. With the bootstrap-seeds directory excluded, the image consists of purely source code, with the exception of the boot sector, which is assembled from hex0 code by rootfs.py, and delivered ready for BIOS to boot.

In kernel bootstrap mode, the kernel (builder-hex0) includes the
ability to assemble hex0 source code, and to execute basic commands,
obviating the need for the bootstrap-seeds subdirectory.
With the bootstrap-seeds directory excluded, the image consists of
purely source code, with the exception of the boot sector, which is
assembled from hex0 code by rootfs.py, and delivered ready for BIOS
to boot.
@Googulator
Copy link
Collaborator Author

This ties in to my plan to support a "verbose" or "auditing" mode, for environments with the highest security/trust requirements, where any source code compiled and/or executed before the first Bash shell would be available is printed to the console, before it has a chance to execute. The console can then be securely recorded for later auditing, preferably by analog means, to ensure that the recording itself can't be compromised.

This way, it's guaranteed that any backdoor code that slips through and attempts to compromise auditing gets printed early enough not to be able to influence its own printing, protecting against e.g. malware that patches the "cat" program to prevent its source code from being examined faithfully.

To do this, I plan to add a "Src" or "SRC" command to builder-hex0's shell, which behaves just like "src", except that it prints what it reads. Passing a "-v" or "--verbose" option to rootfs.py will then cause it to store any file that's not a tarball as a "Src" record, while tarballs remain "src". The ungz, unbz2 and unxz utilities are then extended with their own "-v" option, to print out what they decompress on the fly.

Then, once bash is built, we can pause the bootstrap and drop to an auditing shell, where the rest of the source code can be examined - trust in this shell is ensured by the analog record of it being bootstrapped, containing all the source code that went into it.

Once the auditor is satisfied that the remaining sources are clean, the bootstrap can then proceed from known good source code, with no path for infiltration apart from the 512-byte boot sector, which necessarily executes before it can print anything. The small size of the boot sector prevents any significant payload from being included in it, provided we can make sure that genuinely no more than 512 bytes are read and executed before source code printing begins - see #347 for how to achieve this.

For all of this to work, it's necessary that the srcfs consists entirely of source tarballs and loose source code files. Since bootstrap-seeds contains binaries (by definition), and is unnecessary for kernel bootstrap, it's best to just exclude it from the srcfs.

@stikonas stikonas merged commit 3341de6 into fosslinux:master Feb 14, 2024
6 checks passed
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.

2 participants