-
Notifications
You must be signed in to change notification settings - Fork 233
remote attestation for openfl participants #1561
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
base: develop
Are you sure you want to change the base?
remote attestation for openfl participants #1561
Conversation
@anshubit5516, a couple of general comments regarding the PR quality:
|
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.
LGTM overall, left a few comments from my first review pass.
7ab31cc
to
778e898
Compare
1976cea
to
2dee5d9
Compare
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.
- Would suggest running the formatting script to fix the code formatting pipeline failure.
sh scripts/format.sh
- Tests failing
FAILED tests/openfl/interface/test_aggregator_api.py::test_aggregator_start - KeyError: 'network'
FAILED tests/openfl/interface/test_collaborator.py::test_collaborator_start - TypeError: 'Mock' object is not subscriptable
- Would suggest adding the copyright header in the newly added files.
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 would also suggest adding a page in the documentation to educate the user on how to use this feature.
7b57187
to
b61b328
Compare
ec9891f
to
ac46f46
Compare
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.
It's looking good @anshubit5516, thanks a ton ! I've added a couple of comments from the perspective of how the AttestationManager
would be used downstream (f.e. in OpenFL-Security).
fa1ea06
to
aa7e464
Compare
bc1e8bd
to
f196bed
Compare
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.
LGTM, with a final set of comments:
openfl/interface/collaborator.py
Outdated
if "network" in plan_obj.config and "settings" in plan_obj.config["network"]: | ||
if plan_obj.config["network"]["settings"].get("enable_remote_attestation", False): |
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.
same here
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 check is added as unit tests are sending Mock Object which doesn't have config or is an instance of PLAN. Hence added the check.
openfl/interface/aggregator.py
Outdated
) | ||
# Generate and store the attestation report | ||
attestation_manager.get_attested_identity() | ||
logger.info("Remote attestation report fetched successfully.") |
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.
Why not mention the attestation report path too?
openfl/interface/collaborator.py
Outdated
) | ||
# Generate and store the attestation report | ||
attestation_manager.get_attested_identity() | ||
logger.info("Remote attestation report stored successfully.") |
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.
same
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 don't think signer.py
has anything to do with secagg
, so please consider moving it to openfl.cryptography
or openfl.utilities
, as discussed previously.
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.
+1 to this. It belongs in openfl.cryptography
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 for the PR, @anshubit5516. I see a couple gaps here:
- You have logic to create TLS credentials specific to the enclave, but it doesn't look like it gets used after the ITA report is generated (i.e. in the gRPC server). Am I missing something?
- I have some questions about why a private key path should be passed into the
AttestationManager
. I don't think there's a security hole because I think what's intended is the user runs the docker run command with...gramine-sgx fx aggregator start
as the entrypoint, but generally I think it would be safer to hardcode the path to ensure it's specific to the enclave's local FS - Enabling remote attestation for aggregator / collaborators independently. Secure aggregator running inside SGX will be a very common ask and use case.
- Documentation: What remote attestation is, what problems it solves, and all of the steps to perform it with this PR.
- Tests: I understand it will not be easy to implement for E2E CI because of SGX dependency, but some tests would be useful here given the scope of the changes
from openfl.cryptography.participant import generate_csr | ||
from openfl.federated import Plan | ||
from openfl.interface.cli_helper import CERT_DIR | ||
from openfl.utilities.attestation import attestation_utils as attestation_utils |
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.
Why not this?
from openfl.utilities.attestation import attestation_utils as attestation_utils | |
from openfl.utilities.attestation import attestation_utils |
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.
+1 to this. It belongs in openfl.cryptography
agg_port : auto | ||
hash_salt : auto | ||
use_tls : True | ||
enable_remote_attestation : False |
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 would suggest changing this and moving the enable_remote_attestation
parameter to the aggregator
and collaborator
sections so that it can be configured independently; I expect it will be common that only the aggregator can run inside SGX
Hey @psfoley , thank you for the detailed review!
We envisioned this approach as an initial iteration for 1.9, where the attestation "bundle" (cert+mrenclave+ITA token) is generated, but not wired in OpenFL, and only used E2E in OpenFL-Security (ref. design discussion summary). I understand this is incomplete from an OpenFL perspective, but it was intended as an intermediate step. Now that it becomes clear that the OpenFL-Security changes won't be able to make it into GA, we could consider the following options (among others potentially):
I see, it makes sense. We'll discuss with @anshubit5516 how this can be achieved to align with the usage in OpenFL-Security.
Good point, we'll provide separate properties for those. Maybe we could even start with just the aggregator for this first iteration (
This will be done either in this PR, or in a follow-up one, but it is indeed in scope for the task.
We will discuss with @anshubit5516 what can be done in a non-SGX context (maybe by using mock SGX device files and a mock ITA service?). It may be challenging though, so we will likely primarily rely on the E2E test by QE (manual, to begin with). |
self.privkey_path = ( | ||
privkey_path is not None | ||
and privkey_path | ||
or os.path.join(attestation_report_path, f"{participant_name}_privkey.pem") |
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.
Now that I re-look at this, it is likely not safe to save the private key into the attestation report path. Let's discuss additionally how to deal with this (hard-coded path vs defaults vs other options?).
Please ensure to add documentation changes as well to include this functionality or modify the |
f196bed
to
2071dff
Compare
openfl/interface/aggregator.py
Outdated
# check if remote attestation is enabled | ||
if parsed_plan.config["aggregator"]["settings"].get("enable_remote_attestation", False): | ||
# check if the aggregator is running in a remote attestation environment | ||
attestation_utils.get_remote_attestation(parsed_plan, "aggregator") |
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 pointed out by @psfoley , we will likely need to introduce a fx collaborator certify --import-self-signed
command for the aggregator's attested certificate to be added to each collaborators' trust store.
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
from openfl.utilities.secagg.crypto import ( |
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.
Removing these imports might break the secure aggregation flow. I would suggest keeping them unless it is causing any unexpected issues.
Signed-off-by: Ubuntu <azureuser@ofl-dev-vm-ad-anshumi1.qnxiewjiflyubbpcwut13wv1wh.cx.internal.cloudapp.net>
2071dff
to
30c0a61
Compare
In the last commit I have updated the code so that if enable_remote_attestation is True for Aggregator, then it will generate its own certificate and with the help of env var (ROOT_CERT_PATH) can export its certificate to host. Now if this cert is passed to collaborators use this as root cert it can allow connection to its grpc connection. But catch is we have to disable require_client_auth. It will only work if collaborators certs are available to aggregator before gRPC server starts. |
Summary
As part of approved changes for design discussion, added the changes for providing attestation reports for openFl participants.
Type of Change (Mandatory)
Specify the type of change being made.
Description (Mandatory)
This PR adds basic sgx attestation feature to openFl participants. Feature is controlled via plan flag : enable_remote_attestation. If enable_remote_attestation is True, then before any participant starts, it generates it enclave identity which includes mrenclave/ecdsa key pair and certs/ and attested token of it sgx quote via ITA.
if enable_remote_attestation is True, then there are few additional parameters are required which must be passed an env vars.
Example on how to pass these params :
CERT_HOST_PATH="<host_path>r"
CERT_CONTAINER_PATH="/workspace/attestation/"
docker run --rm
--name "aggregator_container"
--network host
--security-opt seccomp=unconfined
--device=/dev/sgx_enclave
-v /var/run/aesmd/aesm.socket:/var/run/aesmd/aesm.socket
--mount type=bind,source=./cert_agg.tar,target=/certs.tar
--mount type=bind,source=$CERT_HOST_PATH,target=$CERT_CONTAINER_PATH
--env ITA_API_KEY=$ITA_API_KEY
--env AVS_URL=$AVS_URL
--env ATTESTATION_REPORT_PATH=$CERT_CONTAINER_PATH
${workspace_name} bash -c "mkdir -p $CERT_CONTAINER_PATH && tar -xf /certs.tar && gramine-sgx fx aggregator start" > /dev/null 2>&1 &
As summarized in design discussion, currently user is expected to verify the authenticity of other participants manually.
Testing
[Describe the testing done for this PR. If applicable include screenshots.]