-
Notifications
You must be signed in to change notification settings - Fork 128
Implement simple remote attestation for the UEFI app #2742
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
Conversation
| //! A simplified version of the implementation from the `grpc_unary_attestation` | ||
| //! crate. TODO(#2741): Refactor this to share more code between the two runtimes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do some of that before opening this PR, to simplify review, ref #2741
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in #2743
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving this TODO in as some additional refactoring can probably be done with the AttestationHandler here, which mirrors the AttestationServer in the grpc attestation crate. — But redundancy is fairly small, so we can move ahead with this PR for now.
5cdc3d3 to
98e9f9d
Compare
b5538e0 to
e36dbfd
Compare
experimental/uefi/app/src/main.rs
Outdated
| const MOCK_SESSION_ID: [u8; 8] = [0; 8]; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock for now as we only have a single proof of concept client. Will swap this out once I amend the client code to support attestation
conradgrobler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
experimental/uefi/app/src/main.rs
Outdated
| // * `index` - index of the serial port, zero-based. | ||
| // | ||
| // Normally does not return, unless an error is raised. | ||
| fn serial_echo(handle: Handle, bt: &BootServices, index: usize) -> Result<!, uefi::Error<()>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this will conflict with #2745. It is probably a good idea to wait for that to be merged and then rebase on top of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sgtm
| const MOCK_TEE_CERTIFICATE: [u8; 0] = []; | ||
| const MOCK_ADDITIONAL_INFO: [u8; 0] = []; | ||
|
|
||
| impl<F> AttestationHandler<F> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like this is more generic functionality, and could be reused for different scenarios. It might be a good idea to move it somewhere more reusable (either remote_attestation_sessions (my preference) or the new runtime crate from #2745, or even yet another crate (although that is probably overkill)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you mentioned in #2742 (comment) this can be done later as part of #2471
| } | ||
| } | ||
|
|
||
| pub fn message(&mut self, session_id: SessionId, request: Vec<u8>) -> Vec<u8> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should return a Result<Vec<u8>> rather than panic. In the current Oak functions loader Tonic has a handler for request-related tasks that panic, but I think we should not panic anywhere in code for UEFI/bare-metal runtimes unless it is an unrecoverable fatal error that should kill the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I left it like this for the initial remote attestation proof of concept only, but will swap it out for proper error handling by updating this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this PR with basic error handling inside the remote attestation module. However if an error occurs it'll still panic inside the main function of the UEFI app which unwraps any Result of the serial_echo function. Now that's "failed to read message from serial port", "failed remote attestation", "failed to write message to serial port".
We probably don't actually want to panic for "failed remote attestation", and possibly also not for "failed to read message from serial port". Instead we could send an error status code to the companion app, keeping the UEFI app running + serial port open.
I'll open a separate PR for implementing that bit, as it seems best to discuss that in isolation. Probs more related to the general UEFI app <-> loader comms protocol question than to remote attestation specifically.
cc @andrisaar
remove unused deps format oak-prefix crate name for consistency fix typo
| // Needed to expose advanced CPU features to the UEFI app. Specifically | ||
| // RDRAND which is required for remote attestation. | ||
| cmd.arg("-enable-kvm"); | ||
| cmd.args(&["-cpu", "Broadwell-IBRS"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for Broadwell-IBRS? Granted, I don't know what the default CPU that qemu emulates is, but if you want something with RDRAND I think you can explicitly ask for that with +rdrand, something like "-cpu host,+rdrand". I think explicitly listing that we require rdrand is better than hiding it in the CPU definition.
That being said, qemu docs are not the best, so please do check the syntax for the -cpu flag to see how it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for Broadwell-IBRS?
No strong reason for the particular model, other than it supports RDRAND while being old enough that it can hopefully be virtualized by most hosts. This particular line just matches what we went with in #2703.
In general we do want to specify a specific model. The reason is that in virtualization mode, qemu does not use a default CPU. Instead it's either host passthrough (unstable between hosts, not recommended by docs) or a named model. :)
See https://qemu-project.gitlab.io/qemu/system/qemu-cpu-models.html#two-ways-to-configure-cpu-models-with-qemu-kvm for more details
| where | ||
| F: Send + Sync + Clone + FnOnce(Vec<u8>) -> Vec<u8>, | ||
| { | ||
| pub fn create(request_handler: F) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't the normal Rust convention to call these constructor methods new?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there is a loose convention towards new indeed, https://doc.rust-lang.org/nomicon/constructors.html mentions it.
In our codebase we tend to use both create and new in different places , agreed that settling on a convention would be nice though probs out of scope for this. new does seem like a good choice. I choose create here to be consistent with the rest of the remote attestation related structs in the codebase.
|
@andrisaar Could you take a look at the updated version of this PR? (post merging #2745) |
conradgrobler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
andrisaar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, no changes to the uefi app itself!
rebased and ready for review. Implements attestation in the UEFI app side, adding the client side in a separate PR.