Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Why isn't the MRENCLAVE part of the policy for verification? #64

@sbellem

Description

@sbellem

Hi, this repository is very useful to learn about remote attestation and I would like to propose to add the expected MRENCLAVE to the policy file so that it can be part of the verification, but I am not sure how to do so.

Some things to do:

  • Add MRENCLAVE to policy.in file. For development purposes it can first be hardcoded, and if there's some kind of automated way to add it to the policy.in file like it is done for the MRSIGNER, then sure, otherwise, a hardcoded one may be ok, as it would correspond to the version of the code. If the enclave code changes then the hardcoded MRENCLAVE would have to be updated. That seems reasonable for an example, if the reasoning is not flawed.

In enclave_verify.c:

  • Add MRENCLAVE check like it is done for MRSIGNER.
  • The verify_enclave_identity function must be modified to take in the mrenclave as a paramater. Something like:
int verify_enclave_identity(sgx_measurement_t req_mr_signer,
    sgx_measurement_t req_mr_enclave, sgx_prod_id_t req_isv_product_id,
    sgx_isv_svn_t min_isvsvn, int allow_debug, sgx_report_body_t *report)

In sp.cpp:

  • Add to config_struct
typedef struct config_struct {
        // ...
	sgx_measurement_t req_mrsigner;
	sgx_measurement_t req_mrenclave;
	sgx_prod_id_t req_isv_product_id;
	// ...
} config_t;
  • Pass config->req_mrenclave as a parameter to the call to verify_enclave_identity():
		if ( ! verify_enclave_identity(config->req_mrsigner, config->req_mrenclave, 
			config->req_isv_product_id, config->min_isvsvn, 
			config->allow_debug_enclave, r) ) {

			eprintf("Invalid enclave.\n");
			msg4->status= NotTrusted;
		}
  • Take care of command line argument --mrenclave and its processing, and setting the config accordingly.

Others:

  • Header files
  • run.in
  • Windows related files

Reasoning

My understanding is that in order for a remote verifier to be sure that an enclave is running the expected code, the MRENCLAVE in the attestation report must be checked against an expected "trusted" MRENCLAVE. It's not clear to me how a remote verifier is expected to obtain that "trusted" MRENCLAVE, and this example could also demonstrate this, which would be very useful for learning purposes.

For instance, this repository shows how the expected MRSIGNER is extracted out of the SIGSTRUCT from the Enclave.signed.so, using the sgx sdk sgx_sign tool, (and mrsigner program) but how does one get the MRENCLAVE? Are there recommended protocols for the remote verifier to obtain such information?

https://software.intel.com/content/www/us/en/develop/documentation/sgx-developer-guide/top/attestation/remote-interplatform-attestation.html mentions:

The enclave data contained in the quote (MRENCLAVE, MRSIGNER, ISVPRODID, ISVSVN, ATTRIBUTES, and so on.) is presented to the remote service provider at the end of the attestation process. This is the data the service provider will compare against a trusted configuration to decide whether to render the service to the enclave.

But it does not mention how to get this "trusted configuration". This example gives ideas on how to obtain this trusted configuration but it is missing one crucial piece: the MRENCLAVE.

Related: https://community.intel.com/t5/Intel-Software-Guard-Extensions/Who-has-the-original-hash-of-enclave-in-remote-attestation/m-p/1103756#M1136

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions