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

Deny preload for an image with secure boot enabled #2914

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kb2ma
Copy link
Contributor

@kb2ma kb2ma commented Feb 21, 2025

Deny an attempt to preload an app into an image with secure boot enabled, and provide a message to the user. BalenaOS does not support this action.

Implementation includes a generic, callback-driven capability to explore a partition in utils/explore-contents module. Allows for the caller to determine success or failure.

Change-type: patch
Signed-off-by: Ken Bannister <[email protected]>
@kb2ma kb2ma changed the title WIP: Deny preload for an image with secure boot enabled Deny preload for an image with secure boot enabled Feb 26, 2025
@kb2ma kb2ma assigned thgreasi and otaviojacobi and unassigned thgreasi and otaviojacobi Feb 26, 2025
BalenaPartition.ROOTA,
async (fs: typeof Fs): Promise<boolean> => {
try {
const promiseDir = promisify(fs.readdir);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of using promisify here, we can use the native promises api: https://nodejs.org/docs/latest-v20.x/api/fs.html#fspromisesreaddirpath-options to avoid having to do this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rcooke-warwick this is not the fs namespace imported at the top level, but it's the virtual fs "namespace" that balena-image-fs gives us.
That being said, since we recently added support for promises in balena-image-fs, @kb2ma should be able to just use v directly.

Suggested change
const promiseDir = promisify(fs.readdir);
const files = await fs.promises.readdir('/opt');

},
);
// Next verify that config.json enables secureboot.
if (isSecureBoot) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant to this PR, but maybe elsewhere we can add a check to the CLI that detects if someone has tried to enable secureboot on a non signed image, and warn them that this won't work, to avoid any confusion / chance of them thinking they've deployed a secure device but haven't!

}

// Find partition, by partition name on GPT or by filesystem label on MBR.
async function findPartition(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since that's soooo similar to findBootPartitionByName() of balena-config-json, how about avoiding the duplication by creating and exposing a more generic function like the one you did here?
We can then have findBootPartitionByName() use this new findPartition() by wiring in the names of interest for the partition.

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.

4 participants